From 349e40a7771c93ca72b9e66aec73cb98fe25535e Mon Sep 17 00:00:00 2001 From: pk Date: Wed, 13 Aug 2025 16:03:38 +0200 Subject: [PATCH] Make sure the status code is actually returned --- fetch-mixin.js | 4 +++- package.json | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/fetch-mixin.js b/fetch-mixin.js index 7ebf9db..ab0c3f8 100644 --- a/fetch-mixin.js +++ b/fetch-mixin.js @@ -25,6 +25,7 @@ export const fetchMixin = function(superClass) { this.__abortControllers.set(`${method}:${url}`, ac); } + let statusCode = null; try { const reqOptions = { method, @@ -46,6 +47,7 @@ export const fetchMixin = function(superClass) { console.error(resp); } + statusCode = resp.status; if (resp.status !== 200) { document.dispatchEvent(new CustomEvent('request-error', { detail: resp, bubbles: true, composed: true })); } @@ -56,7 +58,7 @@ export const fetchMixin = function(superClass) { return { statusCode: -1, error: err }; } else { this.__abortControllers.delete(`${method}:${url}`); - return { statusCode: null, error: err }; + return { statusCode, error: err }; } } } diff --git a/package.json b/package.json index 6655a86..b219790 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tp/helpers", - "version": "2.8.0", + "version": "2.9.0", "description": "", "main": "closest.js", "scripts": {