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
rawResponse能否给一个method为get的例子?我需要从req中获取get请求传过来的参数,http:127.0.0.1:5173/mock/admin/#?a=1&b=2,我要获取到这个a和b的值,现有的例子是post的
{ url: '/api/text', method: 'post', rawResponse: async (req, res) => { let reqbody = '' await new Promise((resolve) => { req.on('data', (chunk) => { reqbody += chunk }) req.on('end', () => resolve(undefined)) }) res.setHeader('Content-Type', 'text/plain') res.statusCode = 200 res.end(`hello, ${reqbody}`) }, },
The text was updated successfully, but these errors were encountered:
这个看源码就知道怎么处理了,导入一个url模块,用url.parse(req.url, true)就能获得 或者使用response选项,在方法中,用this.req或this.res就能获取到req和res,this.parseJson()就能获取到body参数
Sorry, something went wrong.
No branches or pull requests
rawResponse能否给一个method为get的例子?我需要从req中获取get请求传过来的参数,http:127.0.0.1:5173/mock/admin/#?a=1&b=2,我要获取到这个a和b的值,现有的例子是post的
The text was updated successfully, but these errors were encountered: