我有两个应用。第一个应用程序是一个API,该API部署在heroku及其工作上。
问题是用户到达时
/send
在heroku的nodejs应用程序中结束它应该向我的Web应用程序发送另一个api调用tp保存数据
/保存
该应用程序正在从日志接收heroku上的数据,但未将其发布到其他应用程序端点。
当我使用本地主机时,使用/ save端点将应用发布到另一个Web端点吗?
HEroku显示以下错误?
2020-08-24T13:16:05.014967 + 00:00 app [web.1]: {“ errno”:“ ECONNRESET”,“代码”:“ ECONNRESET”,“ syscall”:“读取”,“ level”:“错误”}
// route.js
app.post('/clinicalchecklist', function (req, res) {
let data = req.body;
winston.info('data received from heroku app', { data });
//call another request here
Service.syncClinicalChecklist(data,function (body) {
//winston.debug("Response is ${body}`);
let json = JSON.parse(JSON.stringify(body));
winston.info(`response is ${json}`);
}, function (err) {
console.log(err);
// res.send("201");
});
res.send("200");
});
// service.js包含另一个请求代码
async syncClinicalChecklist(data,success,error) {
winston.debug(`received data from Kobo `,{data});
winston.info(`received data from Kobo `,{data});
let completionDateIsToday = dateFormat(new Date(), "yyyy-mm-dd");
var jsonData = {
"dataSet": "mJkqMJeDxjY", //clinical checklist
"completeDate": completionDateIsToday,
"period": "2020Q2",
"orgUnit": "EENDe38Diwq",
"dataValues": [
{
"dataElement": "tX",
"value": "1",
"storedBy": "n",
}
};
var options = {
method: 'POST',
url: API_PATH,
body: JSON.stringify(jsonData),
headers: {
'Authorization': 'Basic ' + Buffer.from(user + ':' + password).toString('base64'),
'Accept': 'application/json',
'Content-Type': 'application/json'
},
from: {
mimeType: 'application/json'
}
};
winston.info(`Options for DHIS2`, {options});
this._request(options, function (err, res, body) {
if (err) {
error(err);
return;
}
success(body);
return;
});
}