Business background
Front and back end separate developers
want mock.js
to intercept my request
and then return test data
and so on, after the backend has finished writing the interface, remove mock.js
Business Code
const Mock = require("mockjs");
Mock.mock("http://www.23.com", {
"list|10": ","
});
wx.request({
url: "http://www.23.com",
complete (res) {
console.log(res);
}
});
troubles encountered
- template data of mock can be generated normally in Mini Program
- but the initiated request is not intercepted, but is directly requested to
www.23.com
.
question
- isn"t Mini Program"s request based on XHR? Why can"t you intercept it? is there any way for mock.js to intercept Mini Program"s request
- or is there any other tool other than
mock.js
that can achieve similar functionality? Simultaneously supports various platforms (Mini Program, web pages, etc.)