title: I'm trying to download a pdf file from a node server to a react client but when I open it, it shows blank
body: <p>I'm just reading the data from the file from node and sending the content type as "application/pdf".</p>
  
  <p>My node version is 10.</p>
  
  <p>serverside.js:  </p>
  
  <pre><code>var file = path.join(__dirname,'Rajesh.pdf');
  fs.readFile(file, function(err, data){
      res.contentType("application/pdf");
      res.send(data)
  })
  </code></pre>
  
  <p>clientside.js:</p>
  
  <pre><code>axios.get('/api/downloadcv')
        .then(res =&gt; {
          const url = window.URL.createObjectURL(new Blob([res.data]
            ,{type: "application/pdf"}))
          var link = document.createElement('a');
          link.href = url;
          link.setAttribute('download', 'resume.pdf');
          document.body.appendChild(link);
          link.click();
        })
  </code></pre>
  
  <p>The pdf is getting downloaded but it shows nothing, when I opened it with Vs Code    it showed me something like this:</p>
  
  <p><code>%PDF-1.4
  %äüöß
  2 0 obj
  &lt;&lt;/Length 3 0 R/Filter/FlateDecode&gt;&gt;
  stream
  x��\K�d�m������n�u�F���Ad�d</code></p>