How to Use the User-Agent Header in Axios

Apr 20, 2021

Axios lets you set the User-Agent header using the headers option which allows you to to identify the type of device making the request to the server. The User-Agent property takes a string to tell the server the device making the request. The string follows a structure to properly identify itself. Below is an example:

await axios.get('https://httpbin.org/get', {
  headers: { 'User-Agent':'Axios 0.21.1' }
});

Did you find this tutorial useful? Say thanks by starring our repo on GitHub!

More Axios Tutorials