【发布时间】:2017-08-14 18:28:45
【问题描述】:
在控制台中显示响应,但在邮递员中仅显示发送请求。如何在邮递员中返回有效响应。我如何为这个我尝试了所有的代码编写代码。
这是我目前的代码:
var sendStreamingTemplate = function (req, res) {
authToken = req.headers.authorization;
userAuthObj = JSON.parse(UserAuthServices.userAuthTokenValidator(authToken));
var todayDate = new Date();
var expireDate = new Date(userAuthObj.expire_date);
tokenOK = TokenValidator.validateToken(userAuthObj.user_id, authToken).then(function (userSessions) {
if (userSessions.length === 1) {
if (expireDate >= todayDate) {
StreamingTemplateId = req.params.id;
Template.findById(StreamingTemplateId).then(function (streamingTemplate) {
if (streamingTemplate === null) {
res.status(404).json({
message: 'Streaming not found...'
})
} else {
console.log(streamingTemplate);
switch(streamingTemplate.template_name.toString().toLowerCase()){
case "notification":
//if write return response means it will return something went wrong
break;
case "invoice":
break;
case "voucher":
break;
default:
break;
}
}
}).catch(function (err) {
res.status(500).json({
message: 'something went wrong...'
});
});
} else {
res.status(401).json({
message: 'Not Authorized...'
});
}
} else {
res.status(401).json({
message: 'Token Expired...'
});
}
}).catch(function (err) {
res.status(401).json({
message: 'Token Expired...'
});
});
};
这是控制台的输出:
Instance {
dataValues: {
id: 1, template_name: 'StreamNotification', description: 'Streaming', template_content: 'Mail notification', is_active: true
},
_previousDataValues: {
id: 1, template_name: 'StreamNotification', description: 'Streaming', template_content: 'Mail notification', is_active: true
},
_changed: {
},
}
【问题讨论】:
-
请有人帮帮我
-
“在控制台中显示响应,但在邮递员中仅显示发送这样的请求。我将如何在邮递员中返回响应” 这无助于理解您的问题。正确解释您的问题,以便其他人可以提供帮助。还可以尝试在您的问题中添加一些其他标签,例如
postman。 -
这是我的控制台输出。
-
我也想在邮递员中输出这个。
-
现在在
postman中显示的响应是什么??