title: NodeJS String to Buffer pdf file
body: <p>Hi guys i'm trying to download a pdf file and save it on my disk. The API send me a string. But the following code not working.</p>
  
  <pre><code>axios.get('https://myapi.com/download', config).then((res) =&gt; {
    var buff = Buffer.from(res.data, 'binary');
    fs.writeFile('file.pdf', buff, function (err) {
      if (err) throw err;
      console.log('Saved!');
    });
  }).catch((e) =&gt; {
    console.log(e);
  })
  </code></pre>
  
  <p>I've tried it, and working ...</p>
  
  <pre><code>fs.readFile('./download.pdf','binary', function (err, data) {
    var str = data.toString();
    var buff = Buffer.from(str, 'binary');
    fs.writeFile('novopdf.pdf',buff, () =&gt; {
      console.log('ok');
    })
  });
  </code></pre>