Fixing after react update
This commit is contained in:
@@ -2,12 +2,26 @@ import axios from 'axios';
|
||||
import store from '../store';
|
||||
import { LOGOUT } from '../actions/types';
|
||||
|
||||
<<<<<<< HEAD
|
||||
// Create an instance of axios
|
||||
=======
|
||||
>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb
|
||||
const api = axios.create({
|
||||
baseURL: '/api',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
});
|
||||
<<<<<<< HEAD
|
||||
/*
|
||||
NOTE: intercept any error responses from the api
|
||||
and check if the token is no longer valid.
|
||||
ie. Token has expired or user is no longer
|
||||
authenticated.
|
||||
logout the user if the token has expired
|
||||
*/
|
||||
=======
|
||||
>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb
|
||||
|
||||
api.interceptors.response.use(
|
||||
(res) => res,
|
||||
|
||||
@@ -3,4 +3,7 @@ function formatDate(date) {
|
||||
}
|
||||
|
||||
export default formatDate;
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
|
||||
>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
<<<<<<< HEAD
|
||||
import api from './api';
|
||||
|
||||
// store our JWT in LS and set axios headers if we do have a token
|
||||
|
||||
const setAuthToken = (token) => {
|
||||
if (token) {
|
||||
api.defaults.headers.common['x-auth-token'] = token;
|
||||
localStorage.setItem('token', token);
|
||||
} else {
|
||||
delete api.defaults.headers.common['x-auth-token'];
|
||||
localStorage.removeItem('token');
|
||||
=======
|
||||
import axios from "axios";
|
||||
|
||||
const setAuthToken = (token) => {
|
||||
@@ -7,6 +20,7 @@ const setAuthToken = (token) => {
|
||||
} else {
|
||||
delete axios.defaults.common["x-auth-token"];
|
||||
localStorage.removeItem('token')
|
||||
>>>>>>> cc38df43629d64ca77f694c971a13a026b3afcfb
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user