From fc4a5b0a7f8718d30205e211e28ee4e3ad93e8fd Mon Sep 17 00:00:00 2001 From: Kurt King Date: Fri, 2 Feb 2024 13:09:11 -0700 Subject: [PATCH] fix: returning resp.json() because 204 status responses do not have a json payload Signed-off-by: Kurt King --- plugins/catalog-unprocessed-entities/src/api/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/catalog-unprocessed-entities/src/api/index.ts b/plugins/catalog-unprocessed-entities/src/api/index.ts index 030a4d0293..ae5feedf84 100644 --- a/plugins/catalog-unprocessed-entities/src/api/index.ts +++ b/plugins/catalog-unprocessed-entities/src/api/index.ts @@ -73,11 +73,12 @@ export class CatalogUnprocessedEntitiesClient private async fetch(path: string, init?: RequestInit): Promise { const url = await this.discovery.getBaseUrl('catalog'); const resp = await this.fetchApi.fetch(`${url}/${path}`, init); + if (!resp.ok) { throw await ResponseError.fromResponse(resp); } - return await resp.json(); + return resp.status === 204 ? (resp as T) : await resp.json(); } async pending(): Promise {