diff options
author | Joseph Ditton <jditton.atomic@gmail.com> | 2021-12-08 17:53:18 -0700 |
---|---|---|
committer | Joseph Ditton <jditton.atomic@gmail.com> | 2021-12-08 17:53:18 -0700 |
commit | d7123274e9cade949201d4c801c55ade7224ed0e (patch) | |
tree | c5293eb780a4726a6474e71f2b52f57b9fc21654 | |
parent | 42440a8720ff5afaa72ed1f6f0b21024e76f8e82 (diff) | |
download | locchat-d7123274e9cade949201d4c801c55ade7224ed0e.tar.gz locchat-d7123274e9cade949201d4c801c55ade7224ed0e.zip |
fix api post and put
-rw-r--r-- | client/utils/use_api.js | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/client/utils/use_api.js b/client/utils/use_api.js index aab0293..d167e02 100644 --- a/client/utils/use_api.js +++ b/client/utils/use_api.js @@ -10,12 +10,16 @@ export class Api { authToken = null; makeRequest(url, method, body) { + const options = {}; + if (method === 'POST' || method === 'PUT') { + options.body = JSON.stringify(body); + } return fetch(url, { method, headers: { Authorization: `Bearer ${this.authToken}`, }, - body, + ...options, }).then((res) => res.json()); } |