title: How to convert mongodb response array from javascript object to JSON string
body: <p>I have written a javascript API which returns all the data from mongodb database on request. However it is sending the data s an array of objects and I want to get the simple json string. The statement returning the objects is </p>
  
  <pre><code>return db.collection('variants').find().toArray();
  </code></pre>
  
  <p>Do I need to append another function like JSON.stringify()? but I think that work for single object but not for array of objects as in my case.</p>
  
  <pre><code>var fetch = require('graphql-fetch');
  const API_URL = `http://localhost:4000/graphql`
  const query = `
  {
    variants{
      VARIANT_ID
      CHROM
    }
  }
  `
  fetch(API_URL)(query).then(data =&gt; console.log(data))
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/teDqm.png" rel="noreferrer"><img src="https://i.stack.imgur.com/teDqm.png" alt="enter image description here"></a></p>