Fix an error in fetch.ts (probably the source of these build issues)

This commit is contained in:
Cooper 2024-09-23 11:42:49 +00:00 committed by GitHub
parent fad6316020
commit 7495d51408
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 1 deletions

View File

@ -69,7 +69,12 @@ export async function singularProxiedFetch<T>(
onResponse(context) {
const tokenHeader = context.response.headers.get("X-Token");
if (tokenHeader) setApiToken(tokenHeader);
ops.onResponse?.(context);
if (Array.isArray(ops.onResponse)) {
ops.onResponse.forEach((hook) => hook(context));
} else {
ops.onResponse?.(context);
}
},
});
}