map to new back
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
import router from "@/router";
|
||||
|
||||
function prepareUrl(url) {
|
||||
if (url.startsWith("http")) return url;
|
||||
return `https://astra-dev.dopcore.com/api/${url}`;
|
||||
@@ -15,8 +13,7 @@ function handleRequest(method, url, headers, attempts, body, type) {
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.status === 401) {
|
||||
localStorage.removeItem("tokenAccess");
|
||||
router.go("/login");
|
||||
//router.go("/login");
|
||||
} else if (res) return res.json();
|
||||
})
|
||||
.catch((err) => {
|
||||
@@ -33,13 +30,12 @@ function handleRequest(method, url, headers, attempts, body, type) {
|
||||
* @param {string} type - request type
|
||||
*/
|
||||
function request(method, url, headers = {}, body, type = "") {
|
||||
let token = localStorage.getItem("tokenAccess");
|
||||
let requestOptions = {};
|
||||
if (method === "GET" || method === "DELETE") {
|
||||
requestOptions = {
|
||||
method: method,
|
||||
credentials: "include",
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
...headers,
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
@@ -54,21 +50,21 @@ function request(method, url, headers = {}, body, type = "") {
|
||||
requestOptions = {
|
||||
method: method,
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
Accept: "application/json",
|
||||
...headers,
|
||||
},
|
||||
body: body,
|
||||
credentials: "include",
|
||||
};
|
||||
} else
|
||||
requestOptions = {
|
||||
method: method,
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
Accept: "application/json",
|
||||
"Content-Type": "application/json",
|
||||
...headers,
|
||||
},
|
||||
credentials: "include",
|
||||
body: JSON.stringify(body),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user