[WIP] Фикс запросов, добавил валидацию основных данных

This commit is contained in:
megavrilinvv
2023-08-17 18:17:16 +03:00
parent 65918134ec
commit fbb89646ea
5 changed files with 26 additions and 37 deletions

View File

@@ -45,7 +45,7 @@ function request(method, url, headers = {}, body, type = "") {
requestOptions.body = JSON.stringify(body);
}
}
if (method === "POST" || method === "PUT") {
if (method === "POST" || method === "PUT" || method === "PATCH") {
if (type && type === "formData") {
requestOptions = {
method: method,
@@ -83,6 +83,10 @@ function post(url, body, type, headers, attempts = 3) {
return handleRequest("POST", url, headers, attempts, body, type);
}
function patch(url, body, type, headers, attempts = 3) {
return handleRequest("PATCH", url, headers, attempts, body, type);
}
function put(url, headers, body, attempts = 3) {
return handleRequest("PUT", url, headers, attempts, null, body);
}
@@ -92,4 +96,5 @@ export const fetchWrapper = {
del,
post,
put,
patch,
};