Skip to content

Commit

Permalink
Fixed Metaverse API requests with JSON body.
Browse files Browse the repository at this point in the history
  • Loading branch information
namark committed Apr 4, 2024
1 parent 3751503 commit c98a20b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/modules/metaverse/API.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,13 @@ export class API {
*/
public static async post(path: string, body: FormData | KeyedCollection, metaverseUrl?: string): Promise<unknown> {
const requestConfig = this.buildRequestConfig("POST");
requestConfig.body = body;
requestConfig.body = body instanceof FormData ? body : JSON.stringify(body);
if (!(body instanceof FormData)) {
requestConfig.headers = {
"Accept": "application/json",
"Content-Type": "application/json"
};
}
const response = await fetch(this.buildUrl(path, metaverseUrl), requestConfig);
const data = await response.json() as APIResponse;
// The info and token endpoints do not return data in the usual format.
Expand Down

0 comments on commit c98a20b

Please sign in to comment.