Hello I am quite new to this tool. I am trying to intake a query to perform a search in the atlas app, but am not sure why my code won’t understand the queries given. I am quite new to programming so any help with details would be greatly appreciated
// This function is the endpoint’s request handler.
exports = async function(payload, response) {
query = JSON.stringify(payload.query); //prints out fine
console.log(payload.query.type); //prints out undefined [object Object]
if(payload.query.type){
//prints "message":"Cannot access member 'type' of undefined","name":"TypeError"}
}
const collection = context.services.get("mongodb-atlas").db("portfolio").collection("blogdatas");
let postList = await collection.find().toArray();
postList.forEach(blogdata => {
blogdata._id = blogdata._id.toString();
})
let responseData = {
blogdatas: postList,
query:query,
totalNum: postList.length.toString()
}
return responseData;
};