frontend/src/helpers/http-common.js

16 lines
340 B
JavaScript

import axios from 'axios';
import { API_URL } from '../constants';
const existingToken = JSON.parse(localStorage.getItem('token'));
export const backend = axios.create({
baseURL: API_URL,
headers: {
'Content-type': 'application/json',
},
});
if (existingToken) {
backend.defaults.headers.common['Authorization'] = existingToken;
}