在Mirage的config.js中。例如:
this.get('path/to/endpoint', (schema, request) => {
return '404';
});
应如何格式化返回的响应,以使Mirage像对待真正的404一样对待?
答案 0 :(得分:1)
如果您想用海市rage楼返回“非标准”状态,请将响应添加到动词的末尾。
this.get('path/to/endpoint', undefined, 404);
//OR
this.get('path/to/endpoint', {message:'Nothing found'}, 404);
有关更多信息,请参见route documentation for mirage。
答案 1 :(得分:0)
import Response from 'ember-cli-mirage/response';
this.get('path/to/endpoint', (schema, request) => {
return new Response(404);
});
找到了here。对我来说new Mirage.Response
也工作。