@aspida/node-fetch
Advanced tools
Comparing version 1.4.0 to 1.4.1
@@ -72,4 +72,6 @@ "use strict"; | ||
function HTTPError(response) { | ||
var _newTarget = this.constructor; | ||
var _this = _super.call(this, "HTTP Error: " + response.status + " " + response.statusText) || this; | ||
_this.response = response; | ||
Object.setPrototypeOf(_this, _newTarget.prototype); | ||
return _this; | ||
@@ -76,0 +78,0 @@ } |
{ | ||
"name": "@aspida/node-fetch", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"description": "node-fetch client for aspida", | ||
@@ -29,4 +29,4 @@ "author": "Solufa <solufa2020@gmail.com>", | ||
"dependencies": { | ||
"aspida": "^1.4.0" | ||
"aspida": "^1.4.1" | ||
} | ||
} |
@@ -53,3 +53,7 @@ # @aspida/node-fetch | ||
const fetchConfig = { baseURL: "https://example.com/api" } | ||
const fetchConfig = { | ||
baseURL: "https://example.com/api", | ||
throwHttpErrors: true // throw an error on 4xx/5xx, default is false | ||
} | ||
const client = api(aspida(fetch, fetchConfig)) | ||
@@ -72,3 +76,3 @@ ;(async () => { | ||
// res -> { id: 0, name: "mario" } | ||
} catch (e: HTTPError | Error) { | ||
} catch (e) { | ||
if (e instanceof HTTPError) { | ||
@@ -75,0 +79,0 @@ console.log(e.response instanceof Response) // true |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
14692
134
88
Updatedaspida@^1.4.1