Forum Academy Marketplace Showcase Pricing Features

Modify/Append to list fetched from an External API

I am building an application front-end on Bubble. I am connecting to an external backend using the API connector and I am trying to keep the Bubble backend as ‘stateless’ as possible (maybe using it only for user auth) while storing the permanent states in the external backend.

A particular feature on the front-end has to allow the user to modify a list of composite data types (modify existing fields or add new records). This list is fetched from the external API. I have learned about the ‘saveable’ and ‘non-saveable’ types on Bubble, and also that objects/lists returned from API are non-saveable. The JSON schema of the API response looks like this:

Flow”:{
“name”: “Flow_1”,
FlowSteps”:
[ {“type”: “Input”, “name”: “Input_1”, “num”:1},
{“type”: “Input”, “name”: “Input_2”, “num”:2},
{“type”: “Process”, “name”: “Process_Name”, “num”:3},
{“type”: “Output”, “name”: “Output_1”, “num”:4}]
}
Bubble is able to recognize both Flow and FlowStep as datatypes. The FlowSteps list is used to render an RG making it visible to the user.

Now, one of my requirements is to allow the user to add to the list of FlowStep by taking inputs for name and type.

The challenge here is in ‘creating’ a variable of type FlowStep to hold the name, type, and num of the new list object. I tried everything I could but it seems that Bubble doesn’t allow creating new instances of non-saveable types. One of the forum posts also mentioned the ‘API Ghetto’ which seems to be the problem here as well.

I think there might be a solution in one of the following methods:

  1. Create an additional endpoint in the external API to fetch an empty FlowStep which can be modified before it can be appended to the list. A problem I faced while doing this is that even if the schema of the returned object is the same as FlowStep, Bubble creates a new data type with the same name (FlowStep) when I create a new endpoint for this, making this useless. Moreover, I also have a requirement to modify the existing FlowStep objects which this does not solve.

  2. Server Script - Toolbox
    This tool requires prior knowledge of NodeJS and some conventions which I don’t have. However, this looks the most promising to me. If a script can manipulate the FlowStep list and return a list of the same data type, my problem is solved.

  3. Use Bubble Workflows API: I do not have a subscription yet, so I cannot test this. It will work if it can somehow manipulate “non-Thing” lists.

Repeating again, one of my constraints is not to use the backend DB provided by Bubble. Therefore I cannot store the list as DB entries. These variables (Flow, FlowStep) are fairly temporary and I want them to be deleted once the user closes the webpage. Moreover, I need to put the FlowStep object list back into a POST API call while sending the updates back to the backend. These things incentivize me to keep the fetched data outside the bubble DB.

What would be the best way to solve this?

@keith I have read many answers of yours and others regarding the “API Ghetto” but I couldn’t find a solution for this situation. If I have missed reading something, please do guide me to that source.

Have you tried working directly with the JSON from the API? There are some plugins that let you read/write JSON.

Anyone else have a tip for working directly with JSON?