fix: returning resp.json()

because 204 status responses do not have a json payload

Signed-off-by: Kurt King <kurtaking@gmail.com>
This commit is contained in:
Kurt King
2024-02-02 13:09:11 -07:00
committed by blam
parent 48329dc965
commit fc4a5b0a7f
@@ -73,11 +73,12 @@ export class CatalogUnprocessedEntitiesClient
private async fetch<T>(path: string, init?: RequestInit): Promise<T> {
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<CatalogUnprocessedEntitiesApiResponse> {