Hi,
I have been trying to send each result from results in my db to an endpoint but i keep getting 502 errors and 400 errors, mainly because my server cannot understand my requests or the responses from it. Funny thing is that when i send the exact request with postman, i get a correct response.
My code looks like this
let results = Client.findAll({
where: {
processed: 'Pending'
}
}).then(function (results) {
results.forEach(result => {
var test = JSON.stringify(result);
axios.post('xx.xxx.co.ke/hl7-sync-client', test)
.then(function (response){
console.log("client response",response.body)
// update status of updated appointment
Client.update({ processed: "Processed", date_processed: DATE_TODAY, send_log: response.body.msg }, {
where: {
id: test.id
}
});
})
.catch(function (error){
console.log("client error", error )
Client.update({ date_processed: DATE_TODAY, send_log: error}, {
where: {
id: test.id
}
});
})
});
});
Below is an image of the response i get from my server. Any help will be highly appreciated. Thanks.