We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
module.exports = [ { url: "/api/xxx/query", method: "get", response: async (req, res) => { const params = req.body; const list = await getFile('./xxx/extend.js'); const ret = { code: 'SUCCESS', data: { list }, message: '查询接口成功', success: true, } return ret }, }, ]
以上代码不支持从持久储存(extend.js文件)中异步读取接口信息。返回为{}。 看源码发现requestMiddleware中定义返回部分,尝试对response定义await:
{}
requestMiddleware
const mockResponse = isFunction(response) ? **await** response.bind(self)({ url: req.url, body, query, headers: req.headers }) : response;
可以达到预期返回,求教这样修改是否有影响?如无影响,是否考虑在下个版本中支持异步写法
The text was updated successfully, but these errors were encountered:
+1
Sorry, something went wrong.
feat: Supports both synchronous and asynchronous
2647595
vbenjs/vite-plugin-mock#48
+1 同时需要加sleep() 来模拟真实网络状态
No branches or pull requests
以上代码不支持从持久储存(extend.js文件)中异步读取接口信息。返回为
{}
。看源码发现
requestMiddleware
中定义返回部分,尝试对response定义await:可以达到预期返回,求教这样修改是否有影响?如无影响,是否考虑在下个版本中支持异步写法
The text was updated successfully, but these errors were encountered: