In this part, we will change how the MirageJS server works with the new axios instance that was created. Follow the instructions to do it correctly:
- Open the server.js file in the src/server folder.
- On the routes property in the constructor object, we need to add a passthrough declaration, which will indicate to the MirageJS that all the calls to that URL won't be intercepted:
import { Server } from 'miragejs';
import baseData from './db';
import { getFrom } from './get';
import { postFrom } from './post';
import { patchFrom } from './patch';
import { deleteFrom } from './delete';
window.server = new Server({
seeds(srv) {
srv.db.loadData({ ...baseData });
},
routes() {
this.passthrough();
this.passthrough('https://jsonplaceholder.typicode.com/**');
this.namespace = 'api';
this.timing = 750;
this.get('/users', getFrom('users'));
this...