From 52b743b4f0415cf36fdae9a034db932906d3bddf Mon Sep 17 00:00:00 2001 From: Dan Fernandez Date: Thu, 7 Oct 2021 02:06:38 -0700 Subject: [PATCH] Update README.md to fix HTTPResponseError (#1135) 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 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4d0652dbe..6a9e8dca5 100644 --- a/README.md +++ b/README.md @@ -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; } }