How to make a HTTP GET request in Node.js Express?

Sometimes, we want to make a HTTP GET request in Node.js Express.

In this article, we’ll look at how to make a HTTP GET request in Node.js Express.

How to make a HTTP GET request in Node.js Express?

To make a HTTP GET request in Node.js Express, we can use the axios.get method.

For instance, we write

const axios = require('axios');

const f = async () => {
  const {
    data
  } = await axios.get('https://example.com')
}

to call axios.get with the URL we want to make the GET request to.

axios.get returns a promise that resolves to the response.

Then we get the response data from the data property returned by the promise.

Conclusion

To make a HTTP GET request in Node.js Express, we can use the axios.get method.