Created
July 10, 2018 06:46
-
-
Save aanation/f0d6c79cd27c87a28ca3187d1e7dfdf7 to your computer and use it in GitHub Desktop.
api.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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