File size: 343 Bytes
d542454 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | import { useState, useEffect } from 'react';
import axios from 'axios';
const api = axios.create({
baseURL: '/api',
});
api.interceptors.request.use((config) => {
const token = localStorage.getItem('token');
if (token) {
config.headers.Authorization = `Bearer ${token}`;
}
return config;
});
export default api;
|