Skip to content

Commit

Permalink
Merge pull request #26 from tjg1/fix/rn_default_content_type
Browse files Browse the repository at this point in the history
Set default Content-Type for POST/PUT requests

- Fix: #11
  • Loading branch information
kiwicopple committed Nov 27, 2020
2 parents b87a316 + 008c53a commit f514214
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 f514214

Please sign in to comment.