Problems with axios posting

Hi,

I am trying to post results from a query in nodejs to an enpoint. When i do a post with postman with the expected parameters, i get a successful response, but when i use axios i keep getting an error

data: '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">\n' +
     '<html><head>\n' +
     '<title>400 Bad Request</title>\n' +
     '</head><body>\n' +
     '<h1>Bad Request</h1>\n' +
     '<p>Your browser sent a request that this server could not understand.<br />\n' +
     '</p>\n' +
     '<hr>\n' +
     '<address>Apache/2.4.29 (Ubuntu) Server at localhost Port 80</address>\n' +
     '</body></html>\n' 

My code looks like this

//check unsent appointments
                    connection.query("select * from appointments where processed=0 ", function (err, results, fields) {
                        
                        if(err) {console.log(err)};
        
                        var test = results.forEach(result => {

                            console.log(result);

                            axios.post('test.co.ke/hl7-sync-appointment', result)
                            .then(function (response){
                                console.log(response.data)

                                //update status of updated appointment
                                result = connection.query("update appointments set processed ='1', date_processed ='"+DATE_TODAY+"', send_log='" +response.data +"' where id="+result.id+" ")
                            })
                            .catch(function (error){

                                console.log(error )

                                //update appointment with error
                                result = connection.query("update appointments set date_processed ='"+DATE_TODAY+"', send_log='" +error +"' where id="+result.id+" ")

                            })
                            
                        });

                    });

Any assistance/recommendations will be appreciated. Thanks.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.