fix api post and put

This commit is contained in:
Joseph Ditton 2021-12-08 17:53:18 -07:00
parent 42440a8720
commit d7123274e9

View File

@ -10,12 +10,16 @@ export class Api {
authToken = null; authToken = null;
makeRequest(url, method, body) { makeRequest(url, method, body) {
const options = {};
if (method === 'POST' || method === 'PUT') {
options.body = JSON.stringify(body);
}
return fetch(url, { return fetch(url, {
method, method,
headers: { headers: {
Authorization: `Bearer ${this.authToken}`, Authorization: `Bearer ${this.authToken}`,
}, },
body, ...options,
}).then((res) => res.json()); }).then((res) => res.json());
} }