Skip to content

Commit

Permalink
Allow passing of headers, but don't default
Browse files Browse the repository at this point in the history
  • Loading branch information
aaroncox committed Jan 31, 2024
1 parent 2a013bf commit 0f5861b
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/api/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,16 @@ export class FetchProvider implements APIProvider {
}
}

async call(args: {path: string; params?: unknown; method?: APIMethods}) {
async call(args: {
path: string
params?: unknown
method?: APIMethods
headers?: Record<string, string>
}) {
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 reqHeaders = {
...args.headers,
}
const response = await this.fetch(url, {
method: args.method || 'POST',
Expand Down

0 comments on commit 0f5861b

Please sign in to comment.