title: pdf file not opening in browser
body: <p>I am receiving a pdf file as api call response from a node.js backend.The file opens  in browser window in an encoded format.I have  tried to download but the downloaded file has error opening it (error: failed to load pdf document).I am told the response body is base64 encoded.</p>
  
  <p>Is their any way the pdf can be open /downloaded correctly.I am using react.js and is new to it.</p>
  
  <p><strong>code snippet :</strong></p>
  
  <p>import FileDownload from 'js-file-download';</p>
  
  <pre><code>export function getTaxInvoice({token}){
    const authString = `Bearer ${token}`;
  
    return (dispatch) =&gt; {
      return axios.get(`${MAIN_URL}/rental_invoice`,{
        headers: {Authorization: authString, 'Accept': 'application/json','Content-Type': 'application/pdf'},
        responseType: "arraybuffer",//I have tried with blob as well
        encoding: null
        })
      .then((response)=&gt;{
        FileDownload(response, 'some.pdf');
        const taxInvoiceUrl = window.URL.createObjectURL(new Blob([response.data]));
        window.open(taxInvoiceUrl, "_blank");
        console.log( response); 
        // dispatch(taxInvoiceLoadSuccess(taxInvoiceUrl));
        // dispatch(onViewChanged("rental_invoice"));
      }) 
      .catch((error)=&gt;{
        dispatch(taxInvoiceLoadFailed());
      })
    }
  }
  </code></pre>
  
  <p><strong>response from api call:</strong><a href="https://i.stack.imgur.com/lPabK.png" rel="nofollow noreferrer">image snippet</a></p>