项目用node+express+ejs写的h5页面,所有的数据都是通过调取java第三方接口的数据,然后用ejs渲染,放到测试环境测试的时候不间断的服务挂掉、报错"502 Bad Gateway nginx "错误,请问如何解决呢?是获取接口的数据的问题还是node里面需要配置什么?

router.get(’/:id’,function(req,res,next){

const params = {

id:req.params.id

}

request({

url: ${API}course/detail,

method: req.method,

json: true,

headers: {

“content-type”: “application/json”,

},

qs: params

}, function(error, response, body) {

if (!error && response.statusCode == 200) {

res.render(‘learn’,body)

}

});

})

加了pm2要好点,至少崩了会自动重启,这个是pm2发的错误邮件,新手表示看不懂,哪位能看下用了request和request-promise这两个插件请求数据

at new StatusCodeError (/apps/srv/instance/nodejs/node_modules/request-promise-core/lib/errors.js:32:15)

at Request.plumbing.callback (/apps/srv/instance/nodejs/node_modules/request-promise-core/lib/plumbing.js:104:33)

at Request.RP$callback [as _callback] (/apps/srv/instance/nodejs/node_modules/request-promise-core/lib/plumbing.js:46:31)

at Request.self.callback (/apps/srv/instance/nodejs/node_modules/request/request.js:186:22)

at emitTwo (events.js:106:13)

at Request.emit (events.js:191:7)

at Request. (/apps/srv/instance/nodejs/node_modules/request/request.js:1163:10)

at emitOne (events.js:96:13)

at Request.emit (events.js:188:7)

at IncomingMessage. (/apps/srv/instance/nodejs/node_modules/request/request.js:1085:12)

at IncomingMessage.g (events.js:292:16)

at emitNone (events.js:91:20)

at IncomingMessage.emit (events.js:185:7)

at endReadableNT (_stream_readable.js:974:12)

at _combinedTickCallback (internal/process/next_tick.js:80:11)

at process._tickDomainCallback (internal/process/next_tick.js:128:9)

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐