当我尝试显示带有节点和请求的发布请求的答案时,我遇到了麻烦。我可以在使用中的控制台中看到响应,但是它没有进入控制器。为什么?Thaaaanks!这是代码:function postData(req, res, next){ eventService.getItems() .then(response => { const result = response.body.items const id = nameFilter.map(task => task.id = null) for(var i = 16 ; i < nameFilter.length; i++){ eventService.postData(nameFilter[i]) } }) .then(response => { console.log(response) // undefined res.send(response) }) .catch(error => { console.log('error') next(error) }) }module.exports = {postData}服务 postData(data) { return new Promise(function (resolve, reject) { request.post({ headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer ' + '00002' }, url: 'url ', json: data }, function (error, response, body) { if (error) { reject(error) } else { console.log(response.body) // shows the message resolve(response.body) } }); }) }}
添加回答
举报
0/150
提交
取消