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? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
您好,以下疑问希望解答: function registerRoutes(app) { let mockLastIndex const { mocks } = require('./index.js') const mocksForServer = mocks.map(route => { return responseFake(route.url, route.type, route.response) }) for (const mock of mocksForServer) { app[mock.type](mock.url, mock.response) mockLastIndex = app._router.stack.length } const mockRoutesLength = Object.keys(mocksForServer).length return { mockRoutesLength: mockRoutesLength, mockStartIndex: mockLastIndex - mockRoutesLength } }
// user login { url: '/vue-element-admin/user/login', type: 'post', response: config => { // config 用于模拟请求的配置 他不是后面我们看到的req和res console.log('config', config) console.log('config.body', config.body) const { username } = config.body const token = tokens[username]
// mock error if (!token) { return { code: 60204, message: 'Account and password are incorrect.' } } return { code: 20000, data: token } }
},
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Question(提问)
您好,以下疑问希望解答:
function registerRoutes(app) {
let mockLastIndex
const { mocks } = require('./index.js')
const mocksForServer = mocks.map(route => {
return responseFake(route.url, route.type, route.response)
})
for (const mock of mocksForServer) {
app[mock.type](mock.url, mock.response)
mockLastIndex = app._router.stack.length
}
const mockRoutesLength = Object.keys(mocksForServer).length
return {
mockRoutesLength: mockRoutesLength,
mockStartIndex: mockLastIndex - mockRoutesLength
}
}
// user login
{
url: '/vue-element-admin/user/login',
type: 'post',
response: config => { // config 用于模拟请求的配置 他不是后面我们看到的req和res
console.log('config', config)
console.log('config.body', config.body)
const { username } = config.body
const token = tokens[username]
},
Steps to reproduce(问题复现步骤)
在执行respond(req, res)函数时 为什么没有报错
Other relevant information(格外信息)
The text was updated successfully, but these errors were encountered: