Skip to content

Commit

Permalink
Set default Content-Type for request bodies
Browse files Browse the repository at this point in the history
  • Loading branch information
tjg1 committed Nov 26, 2020
1 parent b87a316 commit 008c53a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib/fetch.ts
Expand Up @@ -38,7 +38,7 @@ export async function post(url: string, body: object, options?: FetchOptions): P
return new Promise((resolve, reject) => {
fetch(url, {
method: 'POST',
headers: options?.headers || {},
headers: { 'Content-Type': 'text/plain;charset=UTF-8', ...options?.headers },
body: JSON.stringify(body),
})
.then((result) => {
Expand All @@ -54,7 +54,7 @@ export async function put(url: string, body: object, options?: FetchOptions): Pr
return new Promise((resolve, reject) => {
fetch(url, {
method: 'PUT',
headers: options?.headers || {},
headers: { 'Content-Type': 'text/plain;charset=UTF-8', ...options?.headers },
body: JSON.stringify(body),
})
.then((result) => {
Expand Down

0 comments on commit 008c53a

Please sign in to comment.