fix api post and put
This commit is contained in:
parent
42440a8720
commit
d7123274e9
@ -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());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user