Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README.md to fix HTTPResponseError #1135

Merged
merged 1 commit into from Oct 7, 2021

Conversation

thedanfernandez
Copy link
Contributor

@thedanfernandez thedanfernandez commented Apr 16, 2021

In the 'Handling client and server errors', the class HTTPResponseError constructor has to call 'super()' before accessing 'this.response'

Not doing this throws the following exception: "ReferenceError: Must call super constructor in derived class before accessing 'this' or returning from derived constructor"

Fix: This just changes the order so super(...) is first, then this.response...

MDN Reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/super#using_super_in_classes

What is the purpose of this pull request?

  • Documentation update
  • Bug fix
  • New feature
  • Other, please explain:

What changes did you make? (provide an overview)
README.md

  • The PR just moves the line this.response = response; to after the super() function as shown below.
		super(`HTTP Error Response: ${response.status} ${response.statusText}`, ...args);
		this.response = response;

Which issue (if any) does this pull request address?

Is there anything you'd like reviewers to know?
Thanks for all that you do :)

In the 'Handling client and server errors', the class HTTPResponseError constructor has to call 'super()' before accessing 'this.response'

Not doing this throws the following exception: "ReferenceError: Must call super constructor in derived class before accessing 'this' or returning from derived constructor"

Fix: This just changes the order so super(...) is first, then this.response...

MDN Reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/super#using_super_in_classes
tekwiz
tekwiz approved these changes Oct 7, 2021
@tekwiz tekwiz requested a review from jimmywarting Oct 7, 2021
@jimmywarting jimmywarting merged commit 52b743b into node-fetch:main Oct 7, 2021
@thedanfernandez thedanfernandez deleted the patch-1 branch Nov 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants