How to make an Axios GET request with params

engrmahabub
Mahabubur Rahman
Published on Nov, 28 2023 1 min read 0 comments
image

Axios is a simple promise based HTTP client for the browser and node.js. Axios provides a simple to use library in a small package with a very extensible interface.

When making a GET request using Axios, you can pass parameters in the URL using the params option. Here's an example of how you can do this:

axios.get('https://xyz.com/get_api', {
  params: {
    p1: 'v1',
    p2: 'v2',
    p3: 'v3'
  }
})
.then(response => {
  console.log(response.data);
})
.catch(error => {
  console.error(error);
});

In this example, the params object contains the parameters that will be appended to the URL as query parameters when the request is made.

0 Comments