Skip to content

Commit

Permalink
use full URL (with query) in API call error message
Browse files Browse the repository at this point in the history
  • Loading branch information
d-fischer committed Mar 6, 2022
1 parent 1c80989 commit 00623bf
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/api-call/src/apiCall.ts
Expand Up @@ -53,7 +53,7 @@ export async function callTwitchApiRaw(
body
};

return await fetch(params ? `${url}${params}` : url, requestOptions);
return await fetch(`${url}${params}`, requestOptions);
}

/**
Expand Down Expand Up @@ -81,10 +81,12 @@ export async function callTwitchApi<T = unknown>(
if (!response.ok) {
const isJson = response.headers.get('Content-Type') === 'application/json';
const text = isJson ? JSON.stringify(await response.json(), null, 2) : await response.text();
const params = stringify(options.query, { arrayFormat: 'repeat', addQueryPrefix: true });
const fullUrl = `${options.url}${params}`;
throw new HttpStatusCodeError(
response.status,
response.statusText,
options.url,
fullUrl,
options.method ?? 'GET',
text,
isJson
Expand Down

0 comments on commit 00623bf

Please sign in to comment.