我正在尝试向我的前端发送一条特定的错误消息。
app.use(function(err, req, res, next){
console.log(err);
});
日志:
[String: 'Error: Request returned error code: 422 and body: {"status":422,"title":"Missing or incorrect required fields","type":"https://developer.bigcommerce.com/api#api-status-codes","errors":{"variant":"This product has options, variant ID is required"}}']
app.use(function(err, req, res, next){
res.status(422).send('TEST TEST TEST');
});
app.use(function(err, req, res, next){
res.status(422).send(err); //Same "err" as scenario 1
});
在scenarion 3
中,我希望在前端看到scenario 1
中记录的内容。有人可以帮我发送variant
消息(从方案1)到前端