diff --git a/src/shared/fetchWrapper.js b/src/shared/fetchWrapper.js index 2cd36ad..3fff02a 100644 --- a/src/shared/fetchWrapper.js +++ b/src/shared/fetchWrapper.js @@ -3,7 +3,7 @@ function prepareUrl(url) { return `/api/${url}`; } -function handleRequest(attempts = 3, method, url, body) { +function handleRequest(method, url, attempts, body) { return new Promise((resolve, reject) => { (function internalRequest() { return request(method, url, body) @@ -44,7 +44,26 @@ function request(method, url, body) { return fetch(url, requestOptions); }; +function get(url, attempts = 1) { + return handleRequest('get', url, attempts); +} + +function del(url, attempts = 1) { + return handleRequest('del', url, attempts); +} + +function post(url, body, attempts = 1) { + return handleRequest('post', url, attempts, body); +} + +function put(url, body, attempts = 1) { + return handleRequest('put', url, attempts, body); +} + export const fetchWrapper = { - handleRequest, - baseUrl: '', + get, + del, + post, + put, + baseUrl: '' }; \ No newline at end of file