【发布时间】:2018-07-25 06:45:24
【问题描述】:
axios({
url: 'myurl.com',
method: 'post',
data:data,})
.then(function(response) {
this.setState({auth:response}); //this is where I want to send express response to
}).catch(function(err) {
console.log(err);
})
这是我的 axios 调用,它将用户输入传递给我的快速路由。
app.post('myurl.com', function(req,res) {
const user = req.body.data
const pass = req.body.otherData
const token = await db.call(req,res,user,pass)
\\ res.json = token ?
})
这是使用用户输入查询数据库的快速路由。这是我想将 db 查询的结果设置为变量并将其作为响应发送回 axios 调用的地方。我正在尝试做的事情是否可能?
【问题讨论】: