summaryrefslogtreecommitdiffstats
path: root/frontend/src/axios.js
blob: f55b37f44a8405824b56b6afc760aa429432bac5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import axios from 'axios';
import { navigate } from '@reach/router';

axios.defaults.baseURL = process.env.REACT_APP_API_BASE_URL || 'http://localhost:4000';
axios.defaults.withCredentials = true;

axios.interceptors.response.use(
  response => {
    // Do something with response data
    return response;
  },
  err => {
    // Do something with response error
    if (err.response && err.response.status === 403) {
      navigate(`/login`);
    }
    return Promise.reject(err);
  },
);

export default axios;