How to use Javascript in bubble

Plugins are a more structured way of bringing a codebase into your app.
For what you’re trying to do I would recommend switching over. Lots written on the forum already to get you started, or you can fork any free plugin and study the syntax that way.

For returning your object you’ve got a few options:

  • The simplest route is to the flatten the object into a one-dimensional array. At it’s simplest this would just be a list of strings / numbers / another type. But you can go deeper by adding multiple data points into each item using a / or similar to separate them. You then bring that array up into Bubble via publishState() and you can then sift, sort, split it.
  • If you really want your object as it is up in Bubble this can also be achieved. This is just as you’re envisaging and once it’s up there though you can traverse the object perfectly - however it’s fiddly to get started. The best place to learn is via this thread. This works both client and server side.
  • Alternatively, just use the API Connector to make your calls for you? That keeps everything in vanilla Bubble and returns your object in a Bubble-ready schema ready to work with.
2 Likes