To call a JSON API with Node.js, we install axios.
To install it, we run
npm install axios
Then we use it by writing
const { data } = await axios.post(url, {
auth: {
username,
password,
},
});
to call axios.post to make a post request to the url with the 2nd argument as the JSON payload.
Then we get the response body from the data property of the object returned by the promise.