From 01df14cc0f8da073aa8305a7cfb0c42bdfd0a2d1 Mon Sep 17 00:00:00 2001 From: Dan Fernandez Date: Fri, 16 Apr 2021 14:48:35 -0700 Subject: [PATCH] Update README.md to fix HTTPResponseError 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 7b68bb304..9fdb5f6cc 100644 --- a/README.md +++ b/README.md @@ -234,8 +234,8 @@ const fetch = require('node-fetch'); class HTTPResponseError extends Error { constructor(response, ...args) { - this.response = response; super(`HTTP Error Response: ${response.status} ${response.statusText}`, ...args); + this.response = response; } }