Javascript 客户端正在从节点服务器捕获一般消息,而不是我尝试发送的消息

Javascript 客户端正在从节点服务器捕获一般消息,而不是我尝试发送的消息,javascript,node.js,Javascript,Node.js,我不确定这里发生了什么,但当我向客户端发回400或其他错误请求时,node正在设置一个通用消息,而不是我要发回的消息。下面是我的服务器上的一个片段,以及客户端UI中的内容 服务器: var noContentFound = { error:true, message:'No data found for this search' } res.status(400).send(noContentFound); return; 客户: .catch(function (error)

我不确定这里发生了什么,但当我向客户端发回400或其他错误请求时,node正在设置一个通用消息,而不是我要发回的消息。下面是我的服务器上的一个片段,以及客户端UI中的内容

服务器:

var noContentFound = {
    error:true,
    message:'No data found for this search'
}
res.status(400).send(noContentFound);
return;
客户:

.catch(function (error) {

    let errorFromServer = {
        generalServerError:{
            error:true,
            message:error.message
        },
        ...
    };

    return errorFromServer;
    //both error, and error.message give the message "Request failed with status code 400"
});
因此,我通过
res.status(400).send(noContentFound)在服务器
noContentFound
对象中发送回错误消息但在客户端,catch函数中返回的唯一内容是
请求失败,状态代码为400
我无法访问我试图发回的消息

奇怪的是,在响应选项卡上的网络选项卡上,我可以看到对象通过。但是
catch
函数中的
error
不允许我访问该对象

有人知道为什么吗

编辑:

客户端调用如下所示: 基本模块:

getContent(obj, envBool, baseUrl, httpRequest)
    .then(function(data){
        //assign to my store object in react and emit the change
    });
在模块中进行呼叫的位置:

const getContent(obj, envBool, baseUrl, httpRequest){

  //set some variables and data to send

  return httpRequest.post(enviUrl,objToSend)
    .then(function(response){
        returnObj = {
            //assign returned data...
        }
        //...
        return returnObj;
    })
    .catch(function(error){
        returnObj = {
            //assign and handle error...
        }
        //...
        return returnObj;
    });

}

检查完整的错误对象。有时它在error.response或error.data中。您是如何在客户端发出http请求的?@FaridNouriNeshat我添加了我的客户端如何发起呼叫您的
400
404
状态在
app.js
中没有通用处理程序吗?我在一些node.js应用程序中看到了这一点。可能发送到客户端的错误被覆盖了。啊,我想这是可能的。我必须调查一下。什么是httpRequest?这个定义在哪里?