import axios from 'axios';
const api = axios.create({
headers: { Authorization: `Bearer ${localStorage.getItem('jwt')}` }
});
api.post('/api/endpoint', data, {
headers: { Authorization: `Bearer ${localStorage.getItem('jwt')}` }
})
.then(response => {
// handle response
})
.catch(error => {
// handle error
});