From 1c61dbc4b69a2522c719845fcf75c306b25ab3e7 Mon Sep 17 00:00:00 2001 From: Jacob Spizziri Date: Thu, 26 Sep 2024 11:09:37 -0400 Subject: [PATCH] fix(request): add a request option that will cause 404's to throw --- src/lib/request.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/lib/request.js b/src/lib/request.js index 8e02f16..c43a40d 100644 --- a/src/lib/request.js +++ b/src/lib/request.js @@ -88,6 +88,13 @@ export default function (relativeUrl, opts, callback) { return fetch(url, config) .then((response) => { + if ( + opts?.requestOptions?.is404Error === true && + response.status === 404 + ) { + throw new Error('404'); + } + if (response.headers.get('content-type').indexOf('application/json') !== -1) { return response.json(); }