Skip to content

Commit

Permalink
Add content-type header (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
apporc authored Jan 30, 2024
1 parent 21b6d69 commit d5c2cae
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/api/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,16 @@ export class FetchProvider implements APIProvider {

async call(args: {path: string; params?: unknown; method?: APIMethods}) {
const url = this.url + args.path

const reqBody = args.params !== undefined ? JSON.stringify(args.params) : undefined
const reqHeaders = {}
if (reqBody) {
reqHeaders['Content-Type'] = 'application/json'
}
const response = await this.fetch(url, {
method: args.method || 'POST',
body: args.params !== undefined ? JSON.stringify(args.params) : undefined,
body: reqBody,
headers: reqHeaders,
})
const text = await response.text()
let json: any
Expand Down

0 comments on commit d5c2cae

Please sign in to comment.