fix(rest): Fix empty Content-Type header (#2537)

* fix(rest): Fix empty Content-Type header

* Update runMethod.ts

* Update runMethod.ts
This commit is contained in:
Andreas Fink
2022-10-20 16:17:29 -05:00
committed by GitHub
parent 7e9d42d7f8
commit b7688bc6b0
+7 -4
View File
@@ -46,12 +46,15 @@ export async function runMethod<T = any>(
);
}
const headers: HeadersInit = {
Authorization: rest.secretKey,
};
if (body) {
headers["Content-Type"] = "application/json";
}
const result = await fetch(`${baseEndpoints.BASE_URL}${route}`, {
body: body ? JSON.stringify(body) : undefined,
headers: {
Authorization: rest.secretKey,
"Content-Type": body ? "application/json" : undefined,
},
headers,
method,
});