My code is very basic. It simply reformats the document into an array of objects. Please ignore the return values of the code in the screenshot because I have since corrected it and created two separate arrays of dates “d.getTime()” and numbers “dates[date][obj]”… instead of one array of objects…
I initially tested the code by bypassing the API input and just creating a value that holds the RAW JSON text, I then parsed it using “JSON.parse(json_object)”. That worked but when I removed that and tried to pull directly from the API (i.e. dates = properties.json_object) it would not work.
I have been researching the issue for hours and trying different things like:
“properties.json_object.get()” and “properties.json_object.get(0, properties.json_object.length());”
← error msgs are telling me these are not functions now
changing the keys and/or return values to be preceded by " _ p_"
parsing the incoming data using JSON.parse(properties.json_object);
making sure it was only reading the body by using (properties.json_object.body);
converting it using JSON.stringify when I was getting errors like “unexpected token o in json at position 1” suggesting it was already parsed
I made a test return value to output the JSON text by outputting “dates” so I could see what the plugin is receiving from the API and it showed [object Object] but when I used JSON.stringify to display it I only saw {“single_api”:true}
I’ll keep searching but I don’t see much detailed documentation in Bubble’s Docs. Any help or pointing me in the right direction that covers any key details that are not in Bubble’s Docs will be greatly appreciated!
I don’t know the answer to this, but I would suggest looking at the code of some free plugins to see how they set it up. There is a free plugin for calendar and I believe it has a timeslot generator feature.
Go to the desired plugin page and press button to see code (only available for free plugins)…it opens the plugin editor for a behind the scenes sneak peak.
So for anyone coming across this issue in the future, I finally found the problems… they were pretty basic but I’m new to making plugins so had to get my bearings with trial and error.
I did not need to:
use get() to cache the JSON document as I thought
convert ‘json-to-bubble-object’ in my situation
JSON.stringify the JSON document
I did need to:
JSON.parse(properties.input) the incoming JSON data prior to processing it with my code
clean up my code
reinitialize my API connection after tinkering with it, it appears that the reason I did not get the option to specify using the “body” of the JSON document was due to my tinkering
make sure I was specifically referencing the “body” of the JSON document in my workflow and not the whole raw text which I initially thought was necessary
Yes, all pretty basic but hopefully this helps a newbie like myself in the future!