Skip to content

Instantly share code, notes, and snippets.

@aanation
Created July 10, 2018 06:46
Show Gist options
  • Save aanation/f0d6c79cd27c87a28ca3187d1e7dfdf7 to your computer and use it in GitHub Desktop.
Save aanation/f0d6c79cd27c87a28ca3187d1e7dfdf7 to your computer and use it in GitHub Desktop.
api.ts
import axiosLib from 'axios';
const axios = axiosLib.create({
baseURL: '/api/v1'
});
axios.interceptors.request.use((config) => {
// твой интерцетор запроса
});
axios.interceptors.response.use(undefined, async(err) => {
// интерцептор обработки ошибки запроса
});
// некий метод получения некоторого нечто
export const getSomeThing = (params) => {
return axios.get('/something', {
params
})
.then(res => res.data);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment