Reputation: 6036
In config.js of Mirage. For example:
this.get('path/to/endpoint', (schema, request) => {
return '404';
});
How should the returned response be formatted so that Mirage treats it like a real 404?
Upvotes: 1
Views: 625
Reputation: 5991
import Response from 'ember-cli-mirage/response';
this.get('path/to/endpoint', (schema, request) => {
return new Response(404);
});
Found here. For me new Mirage.Response
worked too.
Upvotes: 3
Reputation: 4930
If you want to return a "non-standard" status with mirage, add the response to the end of the verb.
this.get('path/to/endpoint', undefined, 404);
//OR
this.get('path/to/endpoint', {message:'Nothing found'}, 404);
See the route documentation for mirage for a little more information.
Upvotes: 1