#Any way to return deserialized json on function response?

10 messages · Page 1 of 1 (latest)

sterile raven
#

It might be my ignorance but the res.json() at the moment returns a seralized json response which I would like to avoid so I can have a clean json response when calling a function

Here is my scenario:
I have created a function to first check if the document in the collection exists and if the document does not exist, it should create it (based on another function) and then return back the document. If it does exist, it simply returns the document. However when I use res.json to return the document and the relevant data, I get a serialized response which the tool I'm using (bubble.io) does not recognize as json and I would like to avoid any extra work on the FE to parse or deserialze the response. How can I use a function to return the processed document rather than relying on the database API and workarounds based on FE logic?

tender wind
#

Hi - let me look into this, response please?

sterile raven
#

I forgot to add how the response looks like.

{
"$id": "643d5ee933394c3a6ac3",
"$createdAt": "2023-04-17T14:59:53.210+00:00",
"$updatedAt": "2023-04-17T14:59:59.059+00:00",
"$permissions": [],
"functionId": "optionsexpiration",
"trigger": "http",
"status": "completed",
"statusCode": 200,
"response": "{"test":"123","dates":["2023-04-14T00:00:00.000+00:00","2023-04-17T00:00:00.000+00:00","2023-04-18T00:00:00.000+00:00","2023-04-19T00:00:00.000+00:00","2023-04-20T00:00:00.000+00:00","2023-04-21T00:00:00.000+00:00","2023-04-28T00:00:00.000+00:00","2023-05-05T00:00:00.000+00:00","2023-05-12T00:00:00.000+00:00","2023-05-19T00:00:00.000+00:00","2023-05-26T00:00:00.000+00:00","2023-06-16T00:00:00.000+00:00","2023-06-30T00:00:00.000+00:00","2023-07-21T00:00:00.000+00:00","2023-08-18T00:00:00.000+00:00","2023-09-15T00:00:00.000+00:00","2023-09-29T00:00:00.000+00:00","2023-10-20T00:00:00.000+00:00","2023-12-15T00:00:00.000+00:00","2023-12-29T00:00:00.000+00:00","2024-01-19T00:00:00.000+00:00","2024-03-15T00:00:00.000+00:00","2024-03-28T00:00:00.000+00:00","2024-06-21T00:00:00.000+00:00","2024-12-20T00:00:00.000+00:00","2025-01-17T00:00:00.000+00:00","2025-06-20T00:00:00.000+00:00"]}",
"stdout": "",
"stderr": "",
"duration": 0.20707106590270996
}

tender wind
#

thanks for sharing!

clever chasm
#

searching for the same response , how can we get a json in the response ? i think i can just json.parse() but sometimes it's a long response and i would avoid computing if possible

quiet plume
#

For now you'll need to parse it.

clever chasm
#

oh thank you , any release date planned ?

quiet plume
#

As I've read a lot of the features planned to be released on version 1.4