Merge pull request #1961 from lts20050703/gh-1939

Fix TypeError: Request with GET/HEAD method cannot have body
This commit is contained in:
Skillz4Killz
2022-02-01 12:04:21 -05:00
committed by GitHub
+4 -4
View File
@@ -23,10 +23,10 @@ export async function runMethod<T = any>(
// For proxies we don't need to do any of the legwork so we just forward the request
if (!url.startsWith(`${BASE_URL}/v${API_VERSION}`) && !url.startsWith(IMAGE_BASE_URL)) {
const result = await fetch(url, {
body: JSON.stringify(body || {}),
body: body ? JSON.stringify(body) : undefined,
headers: {
"Authorization": rest.secretKey,
"Content-Type": "application/json"
Authorization: rest.secretKey,
"Content-Type": "application/json",
},
method: method.toUpperCase(),
}).catch((error) => {
@@ -36,7 +36,7 @@ export async function runMethod<T = any>(
});
if (!result.ok) {
errorStack.message = result.statusText as Error['message'];
errorStack.message = result.statusText as Error["message"];
console.error(`Error: ${errorStack.message}`);
throw errorStack;
}