Skip to content

Instantly share code, notes, and snippets.

@rajasekarm
Created April 2, 2019 16:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rajasekarm/0fd3228dc8a5e1446cca6a47d2028b8f to your computer and use it in GitHub Desktop.
Save rajasekarm/0fd3228dc8a5e1446cca6a47d2028b8f to your computer and use it in GitHub Desktop.
axios global config
import axios from 'axios';
const dev = 'http://localhost:4000/api';
const prod = 'http://your_prod_url/api';
const baseURL = process.env.NODE_ENV === 'production' ? prod : dev;
const axiosInstance = axios.create({ baseURL, timeout: 30000 });
axiosInstance.interceptors.request.use((config) => {
return config;
}, error => Promise.reject(error));
axiosInstance.interceptors.response.use(function (response) {
return response;
}, function (error) {
return Promise.reject(error);
});
export default axiosInstance;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment