Skip to content

Instantly share code, notes, and snippets.

@leandrojo
Last active March 8, 2020 21:19
Show Gist options
  • Save leandrojo/794be46f1e1cbb0f54eadb67dc777dff to your computer and use it in GitHub Desktop.
Save leandrojo/794be46f1e1cbb0f54eadb67dc777dff to your computer and use it in GitHub Desktop.
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;
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,
};
{
"fetch": [
// ...users
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment