Skip to content

Commit

Permalink
fix: Add Content-Type header for POST and PATCH requests (#4)
Browse files Browse the repository at this point in the history
* fix: Add Content-Type header for POST and PATCH requests

* fix: shift POST and PATCH header out of request function
  • Loading branch information
cdoak-gh committed Jan 18, 2024
1 parent 1883655 commit 42a6e64
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ export function post<T = any>(
body?: Record<string, any>,
headers?: Record<string, any>,
): Promise<T> {
return httpRequest(service, "POST", path, undefined, body, headers);
const postHeaders = {
...headers,
["Content-Type"]: "application/json"
};
return httpRequest(service, "POST", path, undefined, body, postHeaders);
}

export function patch<T = any>(
Expand All @@ -40,7 +44,11 @@ export function patch<T = any>(
body?: Record<string, any>,
headers?: Record<string, any>,
): Promise<T> {
return httpRequest(service, "PATCH", path, undefined, body, headers);
const patchHeaders = {
...headers,
["Content-Type"]: "application/json"
};
return httpRequest(service, "PATCH", path, undefined, body, patchHeaders);
}

export function httpDelete<T = any>(
Expand Down

0 comments on commit 42a6e64

Please sign in to comment.