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;
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());
}