在mirajeJS的帮助下,我们可以模拟路由,但是,如果这样的路由不是用mirajeJS模拟的,有没有可能重定向它并使用使用axios的真实服务器?
import {Server} from "miragejs";
new Server({
routes() {
this.namespace = "api/";
this.get("test/router", () => {
return [
{name: "Angy", surname: "T."},
{name: "Chris", surname: "B."},
{name: "Juliana", surname: "Crain"}
];
});
}
});也就是说,我希望实现以下行为,我对测试/路由器请求进行了修改,但如果用户发出了未在Miraje中锁定的任何其他请求,则它将转到真实服务器,即使用真实的请求
发布于 2021-05-29 07:27:16
您可以使用这样的直通
new Server({
routes() {
this.namespace = "api/";
this.get("test/router", () => {
return [
{name: "Angy", surname: "T."},
{name: "Chris", surname: "B."},
{name: "Juliana", surname: "Crain"}
];
});
// Allow unhandled requests on the current domain to pass through
this.passthrough();
}
});https://stackoverflow.com/questions/67456650
复制相似问题