title: CSV convert to JSON Returning as an empty array
body: <p>I have an API route in my next.js project, the idea is that it process the stats from an API the company I work for is using. It makes it's way through the whole function without issue until it comes time to convert the CSV to a JSON array, then it just returns as <code>[]</code></p>
  <p>I figured out if I remove the CSVtoJSON conversion code and run to download the file, then alter the code so it has the CSVtoJSON code but removing the download of the file it will parse the CSV into the JSON I want without issue.</p>
  <p>I am using asyn/await functions so I am not sure why it is reading the file as empty when I try to run it as one whole function but not if I run each chunk individually.</p>
  <pre><code>// logs.ts
  import {NextApiRequest, NextApiResponse} from 'next'
  import {processStats, fetchCsv, downloadFile} from './functions'
  
  export default async (req: NextApiRequest, res: NextApiResponse) =&gt; {
   const request = await processStats(1, 1, 'UTC', 'records', 'calls')
   const csv_url = await fetchCsv(request.request_id)
   const parsedf = await downloadFile(csv_url.download_url)
   res.status(200).json(parsedf)
  }
  </code></pre>
  <pre><code>// downloadFile function
  export async function downloadFile(url) {
    const fs = require('fs')
    const https = require('https')
    const csv = require('csvtojson')
  
    const fp = await fs.createWriteStream('pages/api/stats/data.csv')
    const req = await https.get(url, function (res) {
      res.pipe(fp)
    })
  
    const jsonArray = await csv().fromFile('pages/api/stats/data.csv')
    return jsonArray
  }
  </code></pre>
  <p>No errors are thrown it just sends back the empty <code>[]</code> array.</p>
  <p>Any help would be amazingly appreciated.</p>
  <p>Mac</p>