Lint request.js
This commit is contained in:
parent
14a0f19aa8
commit
2beb872de9
@ -1,12 +1,12 @@
|
|||||||
import axios from 'axios'
|
import axios from "axios"
|
||||||
|
|
||||||
// This functions returns an axios instance, the token is added to the
|
// This functions returns an axios instance, the token is added to the
|
||||||
// configuration if found in the localStorage
|
// configuration if found in the localStorage
|
||||||
export function configureAxios(headers = {}) {
|
export function configureAxios(headers = {}) {
|
||||||
// Get the token from the localStorate
|
// Get the token from the localStorate
|
||||||
const token = localStorage.getItem('token');
|
const token = localStorage.getItem("token");
|
||||||
if (token) {
|
if (token) {
|
||||||
headers = { 'Authorization': `Bearer ${token}` };
|
headers = { "Authorization": `Bearer ${token}` };
|
||||||
}
|
}
|
||||||
|
|
||||||
return axios.create({
|
return axios.create({
|
||||||
@ -30,10 +30,10 @@ export function request(eventPrefix, promise, callbackEvents = null, mainPayload
|
|||||||
})
|
})
|
||||||
promise
|
promise
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (response.data.status === 'error')
|
if (response.data.status === "error")
|
||||||
{
|
{
|
||||||
dispatch({
|
dispatch({
|
||||||
type: 'ADD_ALERT_ERROR',
|
type: "ADD_ALERT_ERROR",
|
||||||
payload: {
|
payload: {
|
||||||
message: response.data.message,
|
message: response.data.message,
|
||||||
main: mainPayload,
|
main: mainPayload,
|
||||||
@ -58,11 +58,11 @@ export function request(eventPrefix, promise, callbackEvents = null, mainPayload
|
|||||||
// Unauthorized
|
// Unauthorized
|
||||||
if (error.response && error.response.status == 401) {
|
if (error.response && error.response.status == 401) {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: 'USER_LOGOUT',
|
type: "USER_LOGOUT",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
dispatch({
|
dispatch({
|
||||||
type: 'ADD_ALERT_ERROR',
|
type: "ADD_ALERT_ERROR",
|
||||||
payload: {
|
payload: {
|
||||||
message: error.response.data,
|
message: error.response.data,
|
||||||
main: mainPayload,
|
main: mainPayload,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user