Passing headers with axios POST request

When using Axios, in order to pass custom headers, supply an object containing the headers as the last argument Modify your Axios request like: const headers = { ‘Content-Type’: ‘application/json’, ‘Authorization’: ‘JWT fefege…’ }, data, { headers: headers }) .then((response) => { dispatch({ type: FOUND_USER, data:[0] }) }) .catch((error) => { dispatch({ type: … Read more

How to download files using axios

A more general solution axios({ url: ‘’, //your url method: ‘GET’, responseType: ‘blob’, // important }).then((response) => { const url = window.URL.createObjectURL(new Blob([])); const link = document.createElement(‘a’); link.href = url; link.setAttribute(‘download’, ‘file.pdf’); //or any other extension document.body.appendChild(link);; }); Check out the quirks at Full credits to: