I am sending an object from Google Apps Script through a webhook to Mongo Stitch (with a http service). The input object is {A=185, B=8, C=200} and once inserted into the DB it becomes {A="185", B="8", C="200"}. How do I avoid the numbers being converted to string when saved in the DB?
On Google Apps Script-side I have:
function sendToStitch(){
var obj = {A=185, B=8, C=200};
var options = {
'method' : 'post',
'payload' : obj
};
var insertID = UrlFetchApp.fetch('https://eu-west-1.aws.webhooks.mongodb-stitch.com/api/client/v2.0/app/timesheetstest-fgidp/service/sheets/incoming_webhook/import', options);
}
On Stitch-side I have in a http service:
exports = async function(payload) {
const mongodb = context.services.get("mongodb-atlas");
const eventsdb = mongodb.db("time");
const eventscoll = eventsdb.collection("sheets");
const result = await eventscoll.insertOne(payload.query);
var id = result.insertedId.toString();
if(result) {
return JSON.stringify(id,false,false);
}
return { text: `Error saving` };
}
How can I make sure that the object values are inserted with a number type? (same as in the input object, I verified this Google Apps Script-side).
Any suggestions?
Thanks!