Sometimes, we want to make a remote REST call with Node.js.
In this article, we’ll look at how to make a remote REST call with Node.js.
How to make a remote REST call with Node.js?
To make a remote REST call with Node.js, we can use axios
.
We install it by running
npm i axios
Then we use it by writing
const url = `https://example.com`;
const {
data
} = await axios({
method: 'get',
url,
})
to call axios
with the 'get'
request method
and the request url
.
It returns a promise with the response data stored in data
.
Conclusion
To make a remote REST call inside Node.js, we can use axios
.