reactjs - 访问 API 后 Axios 未显示数据响应
问题描述
从客户端应用程序调用 GET 请求
axios.get('http://localhost:5000/users/login',user)
.then((res) => {
console.log(res);
});
GET 请求接口
User.findOne({email: email})
.then(docs => {
bcrypt.compare(password , docs.password, function(err, result) {
if(result){
return response.status(200).json({message : 'user found'})
}else{
return res.send(err);
} });})
.catch(Err => response.send(Err))
解决方案
您也没有在回复中将用户发回。
你有return response.status(200).json({message : 'user found'})
您正在收到回复(根据您帖子中的图片判断)。但你也想发送result
.
推荐阅读
- azure - 执行 DownloadToFIleParallelAsync 方法时的问题
- java - Java:确定两个正则表达式模式是否重叠
- node.js - 带有heroku的axios
- ubuntu - 无限 .sh 文件 Python
- c# - 子类字段可以在父类中使用吗?
- javascript - 格式化日期(YYYY-MM-DD 到 2018 年 12 月 2 日)- JavaScript
- html - 在Angular 5的模板中访问或显示嵌套json数组的项目
- backup - 将 Windows 服务器上的文件和文件夹备份到 NAS
- jmeter - 使用 POST 使用 jmeter 上传 REST API 文件
- css - Sass 循环 @mixin 和 @include