Skip to content

Commit

Permalink
fix(utils/web): Fix typo in Content-Type header
Browse files Browse the repository at this point in the history
Reasons:
- RFC says it's Content-Type, not Content-type
- node-fetch package is checking for the `Content-Type` header in a case sensitive manner and overwrites it when cannot find it https://github.com/node-fetch/node-fetch/blob/master/src/request.js#L71
- because of the node-fetch Content-Type check, the header is sometimes overwritten and near-api-js call is not always recognized as application/json request
  • Loading branch information
rlisowski authored and frol committed Dec 2, 2020
1 parent 67400fa commit 34f4771
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/utils/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export async function fetchJson(connection: string | ConnectionInfo, json?: stri
const response = await fetch(url, {
method: json ? 'POST' : 'GET',
body: json ? json : undefined,
headers: { 'Content-type': 'application/json; charset=utf-8' }
headers: { 'Content-Type': 'application/json; charset=utf-8' }
});
if (!response.ok) {
if (response.status === 503) {
Expand Down

0 comments on commit 34f4771

Please sign in to comment.