Home > other >  How can I make this API call from my Nodejs program?
How can I make this API call from my Nodejs program?

Time:09-27

A member of my team developed this API where you send some numeric values and it gives you back a probability. He deployed it in Heroku and sent me the task of connecting it with our backend, you can make the call from cmd like this:

curl -d "{\"Values\":[[value1,value 2,value 3,value 4,value 5]]}" -H "Content-Type: application/json" -X POST https://apibc1.herokuapp.com/predict

And it will work just like intended, but to be honest I don't know how to make this call in my server file, I'm trying to use the request package in Node but I keep getting the invalid URI error on my logs. An example of the API working from cmd: enter image description here
And this is what happens when I make the same call in my server.js file:
enter image description here

CodePudding user response:

If you have a working curl you can import it into postman and generate a working code sample for a lot of languages.

  1. Import the curl request

enter image description here

  1. Then click the code button on the right

enter image description here

  1. and select a language/framework option from the dropdown

enter image description here

  • Related