I wrote a javascript API which, upon request, returns all the data from the mongodb database. However, it sends data to an array of objects, and I want to get a simple json string. Operator returning objects
return db.collection('variants').find().toArray();
Do I need to add another function like JSON.stringify ()? but I think the work is for a single object, but not for an array of objects, as in my case.
var fetch = require('graphql-fetch'); const API_URL = `http://localhost:4000/graphql` const query = ` { variants{ VARIANT_ID CHROM } } ` fetch(API_URL)(query).then(data => console.log(data))

json javascript mongodb bson
Mian asbat ahmad
source share