Skip to content

Commit

Permalink
Update README.md to fix HTTPResponseError (#1135)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
thedanfernandez committed Oct 7, 2021
1 parent acc2cba commit 52b743b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -240,8 +240,8 @@ import fetch from 'node-fetch';

class HTTPResponseError extends Error {
constructor(response, ...args) {
this.response = response;
super(`HTTP Error Response: ${response.status} ${response.statusText}`, ...args);
this.response = response;
}
}

Expand Down

0 comments on commit 52b743b

Please sign in to comment.