Fixing the cross origine on the frontend side
This commit is contained in:
parent
b88d820c12
commit
21de520175
@ -1,7 +1,7 @@
|
|||||||
import { restGet, restPost } from './restConsumer.js'
|
import { restGet, restPost } from './restConsumer.js'
|
||||||
|
|
||||||
export async function login(user, pass, exp){
|
export async function login(user, pass, exp){
|
||||||
return restPost("/login", {login: user, password: pass, expiration: exp});
|
return restPost("/login", {identifier: user, password: pass, expiration: exp});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function register(user, pass, mail){
|
export async function register(user, pass, mail){
|
||||||
|
@ -8,15 +8,15 @@ export async function restGet(endPoint) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function restPost(endPoint, data) {
|
export async function restPost(endPoint, data) {
|
||||||
return await _rest(endPoint, {method: "POST", body: data});
|
return await _rest(endPoint, {method: "POST", body: JSON.stringify(data)});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function restDelete(endPoint, data) {
|
export async function restDelete(endPoint, data) {
|
||||||
return await _rest(endPoint, {method: "DELETE", body: data});
|
return await _rest(endPoint, {method: "DELETE", body: JSON.stringify(data)});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function restPatch(endPoint, data) {
|
export async function restPatch(endPoint, data) {
|
||||||
return await _rest(endPoint, {method: "PATCH", body: data});
|
return await _rest(endPoint, {method: "PATCH", body: JSON.stringify(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,8 +31,12 @@ export async function restPatch(endPoint, data) {
|
|||||||
async function _rest(endPoint, config){
|
async function _rest(endPoint, config){
|
||||||
endPoint.at(0) != "/" ? console.error("Carefull, you certainly should put a / at the begenning of your endPoint ") : true;
|
endPoint.at(0) != "/" ? console.error("Carefull, you certainly should put a / at the begenning of your endPoint ") : true;
|
||||||
let session_token = getCookie("session_token");
|
let session_token = getCookie("session_token");
|
||||||
let headers = new Headers({'Authorization': session_token});
|
let headers = new Headers({
|
||||||
|
'Authorization': session_token,
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
});
|
||||||
config['headers'] = headers;
|
config['headers'] = headers;
|
||||||
|
config['credentials'] = 'include'
|
||||||
return toast.promise(fetch(restURL + endPoint, config),
|
return toast.promise(fetch(restURL + endPoint, config),
|
||||||
{
|
{
|
||||||
pending: config['pending'] != null ? config['pending'] : 'pending',
|
pending: config['pending'] != null ? config['pending'] : 'pending',
|
||||||
|
Loading…
Reference in New Issue
Block a user