Open sws797 opened 2 years ago
注释掉src/mock-server.js第49行
app.use(bodyParser.json())
@laozei6401 额,没有用啊
@laozei6401 试了一下,不行。两个issue不一样,那边是 post 超时,这边是将
login({ username: username.trim(), password: password })
改成
const formData = new FormData();
formData.append(....)
login(formData)
后,config.body = {}
了。我觉得一般人应该不会在post请求里专门写 FormData,但是这样写后抓不了了
Bug report(问题描述)
将API中post相关请求的参数包装到
formData
中后,就不能识别了body-parser
难道不能解析formData
吗?Steps to reproduce(问题复现步骤)
src/store/modules/user.js
改成如下方式login({ commit }, userInfo) { const { username, password } = userInfo return new Promise((resolve, reject) => { const formData = new FormData() formData.append('username', username.trim()) formData.append('password', password) login(formData).then(response => { const { data } = response commit('SET_TOKEN', data.token) setToken(data.token) resolve() }).catch(error => { reject(error) }) }) },
...
{ url: '/vue-element-admin/user/login', type: 'post', response: config => { console.log(config.body) ... } }