Enrich external API failure audit metadata
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
import { fetchJson, parseApiErrorMessage, saveJsonObject } from './jsonClient';
|
||||
import {
|
||||
appendApiErrorRequestId,
|
||||
fetchJson,
|
||||
parseApiErrorMessage,
|
||||
saveJsonObject,
|
||||
} from './jsonClient';
|
||||
|
||||
export const EDITOR_API_BASE_PATH = '/api/editor';
|
||||
export const ASSETS_API_BASE_PATH = '/api/assets';
|
||||
@@ -69,7 +74,7 @@ export async function postApiJson<T>(
|
||||
const responseText = await response.text();
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(parseApiErrorMessage(responseText, fallbackMessage));
|
||||
throw new Error(appendApiErrorRequestId(parseApiErrorMessage(responseText, fallbackMessage), response.headers.get('x-request-id')));
|
||||
}
|
||||
|
||||
return responseText ? (JSON.parse(responseText) as T) : ({} as T);
|
||||
|
||||
Reference in New Issue
Block a user