From d7123274e9cade949201d4c801c55ade7224ed0e Mon Sep 17 00:00:00 2001 From: Joseph Ditton Date: Wed, 8 Dec 2021 17:53:18 -0700 Subject: [PATCH] fix api post and put --- client/utils/use_api.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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()); }