Last active
March 8, 2020 21:19
-
-
Save leandrojo/794be46f1e1cbb0f54eadb67dc777dff to your computer and use it in GitHub Desktop.
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 axios from 'axios'; | |
import MockAdapter from 'axios-mock-adapter'; | |
const api = axios.create({ | |
baseURL: '...', | |
}); | |
export const mock = new MockAdapter(api, { delayResponse: 2000 }); | |
export default api; |
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 api, { mock } from './api'; | |
mock.onGet('/users').reply(200, require('./users.json').fetch); | |
const fetch = async () => { | |
const response = await api.get('/users'); | |
return response.data; | |
}; | |
export default { | |
fetch, | |
}; |
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
{ | |
"fetch": [ | |
// ...users | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment