Fix APIClient
This commit is contained in:
parent
88e8a8b8a3
commit
8ba45f84cb
@ -9,6 +9,7 @@ export function* loginSaga(action) {
|
|||||||
try {
|
try {
|
||||||
result = yield call(client.login, action.username, action.password);
|
result = yield call(client.login, action.username, action.password);
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
|
console.error(err);
|
||||||
yield put(loginFailure(action.username, err));
|
yield put(loginFailure(action.username, err));
|
||||||
yield put(addMessage('danger', "Une erreur inconnue bloque le fonctionnement normal de l'application. Veuillez réessayer plus tard."));
|
yield put(addMessage('danger', "Une erreur inconnue bloque le fonctionnement normal de l'application. Veuillez réessayer plus tard."));
|
||||||
return
|
return
|
||||||
@ -44,4 +45,3 @@ export function* logoutSaga(action) {
|
|||||||
|
|
||||||
yield put(logoutSuccess(action.username));
|
yield put(logoutSuccess(action.username));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,13 +38,13 @@ export class APIClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_callAPI(path, body, method='GET') {
|
_callAPI(path, body, method='GET') {
|
||||||
return fetch(baseURL + path, {
|
return fetch(this.baseURL + path, {
|
||||||
method,
|
method,
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
mode: 'cors',
|
mode: 'cors',
|
||||||
credentials: true,
|
credentials: 'include',
|
||||||
body: JSON.stringify(body),
|
body: JSON.stringify(body),
|
||||||
})
|
})
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
|
Loading…
Reference in New Issue
Block a user