Skip to content

Commit

Permalink
Merge pull request #59 from fireblocks/fix-undefined-idemp-key
Browse files Browse the repository at this point in the history
bugfix: when Idempotency key is undefined, axios fails
  • Loading branch information
yarinvak authored Nov 24, 2021
2 parents ce86d8b + 33cdd37 commit 1111e52
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,17 @@ export class ApiClient {
const token = this.authProvider.signJwt(path, body);

const idempotencyKey = requestOptions?.idempotencyKey;
const headers: any = {
"X-API-Key": this.authProvider.getApiKey(),
"Authorization": `Bearer ${token}`,
};

if (idempotencyKey) {
headers["Idempotency-Key"] = idempotencyKey;
}

return (await this.axiosInstance.post(path, body, {
headers: {
"X-API-Key": this.authProvider.getApiKey(),
"Authorization": `Bearer ${token}`,
"Idempotency-Key": idempotencyKey
},
headers,
timeout: this.options.timeoutInMs
})).data;
}
Expand Down

0 comments on commit 1111e52

Please sign in to comment.