在幻影的config.js里。例如:
this.get('path/to/endpoint', (schema, request) => {
return '404';
});应该如何格式化返回的响应,以使幻影将其视为真正的404?
发布于 2018-07-25 00:38:02
如果你想返回一个“非标准”的mirage状态,可以在动词的末尾添加响应。
this.get('path/to/endpoint', undefined, 404);
//OR
this.get('path/to/endpoint', {message:'Nothing found'}, 404);有关更多信息,请参阅route documentation for mirage。
发布于 2018-07-25 18:43:58
import Response from 'ember-cli-mirage/response';
this.get('path/to/endpoint', (schema, request) => {
return new Response(404);
});找到here。对我来说,new Mirage.Response也起作用了。
https://stackoverflow.com/questions/51502936
复制相似问题