首页 > 解决方案 > 访问 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))

邮递员回复消息

来自客户端控制台的空正文数组

标签: reactjsmongodbaxiosbcryptjsonresponse

解决方案


您也没有在回复中将用户发回。

你有return response.status(200).json({message : 'user found'})

您正在收到回复(根据您帖子中的图片判断)。但你也想发送result.


推荐阅读