當我嘗試顯示帶有節點和請求的發布請求的答案時,我遇到了麻煩。我可以在使用中的控制臺中看到響應,但是它沒有進入控制器。為什么?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) } }); }) }}
發布請求后無法顯示回復
慕容森
2021-05-10 13:14:13