Mongo Collection double values coming to SendGrid template weirdly

image
This is how a double value from an array of nested documents gets printed out in SendGrid. I was wondering if anyone has had a similar experience? I am sending the array in my request to SendGrid. Then in the template, I am looping through the array and accessing properties.

I have seen similar strange things happen with MongoDB collection values when they get sent over http.

Anyone had similar experiences? Know a remedy?

Hi @Lukas_deConantseszn1,

This looks like a response from a realm webhook? Correct me if I am wrong.

If so this is sent as extended json standard where types are represented this way.

You can parse them into plain json before you return them :

JSON.parse(JSON.stringify(doc))

Thanks
Pavel

This data is happening in a realm function that is querying the collection with its atlas service.

But how is the client access the data? Is it a web sdk or a webhook url?

Realm function runs once a day, queries data, then sends it in an API request to SendGrid. SendGrid email template then reads the data like this.

You use http service to send data? Have you used the encodeBodyAsJson flag,?

Have you tried to parse it to json before ?

Thanks
Pavel

I use context.http.post and I use encodeBodyAsJson set to true.

I tried the JSON.Stringify JSON.Parse thing and it sadly didn’t work. I’m going to try to parseFloat on the value itself next.

I switched to using axios in my realm function. context.http just has problems :slight_smile:

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.