From 81f5ec274137308598bd85cf6b002eafef4dd208 Mon Sep 17 00:00:00 2001 From: Daria Golova Date: Wed, 15 Jun 2022 14:36:23 +0300 Subject: [PATCH] fix methods --- src/shared/fetchWrapper.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/shared/fetchWrapper.js b/src/shared/fetchWrapper.js index 3fff02a..d6f420a 100644 --- a/src/shared/fetchWrapper.js +++ b/src/shared/fetchWrapper.js @@ -23,15 +23,15 @@ function handleRequest(method, url, attempts, body) { function request(method, url, body) { let controller = new AbortController; let requestOptions = {}; - if (method === 'get' || method === 'del'){ + if (method === 'GET' || method === 'DELETE'){ requestOptions = { - method: `${method.toUpperCase()}`, + method: method, signal: controller.signal, } }; - if (method === 'post' || method === 'put'){ + if (method === 'POST' || method === 'PUT'){ requestOptions = { - method: `${method.toUpperCase()}`, + method: method, headers: { Accept: 'application/json', 'Content-Type': 'application/json', @@ -45,19 +45,19 @@ function request(method, url, body) { }; function get(url, attempts = 1) { - return handleRequest('get', url, attempts); + return handleRequest('GET', url, attempts); } function del(url, attempts = 1) { - return handleRequest('del', url, attempts); + return handleRequest('DELETE', url, attempts); } function post(url, body, attempts = 1) { - return handleRequest('post', url, attempts, body); + return handleRequest('POST', url, attempts, body); } function put(url, body, attempts = 1) { - return handleRequest('put', url, attempts, body); + return handleRequest('PUT', url, attempts, body); } export const fetchWrapper = {