# I'm having trouble processing data in Bubble.io with JavaScript! 🤯

**URL:** <https://forum.bubble.io/t/im-having-trouble-processing-data-in-bubble-io-with-javascript/344411>\
**Category:** APIs\
**Created:** [October 15, 2024, 10:08pm UTC](https://forum.bubble.io/t/im-having-trouble-processing-data-in-bubble-io-with-javascript/344411 "2024-10-15T22:08:33Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![maximilien.godeau.of](https://avatars.discourse-cdn.com/v4/letter/m/35a633/32.png) [@maximilien.godeau.of](https://forum.bubble.io/u/maximilien.godeau.of)\
**Post date:** [October 15, 2024, 10:08pm UTC](https://forum.bubble.io/t/im-having-trouble-processing-data-in-bubble-io-with-javascript/344411/1 "2024-10-15T22:08:33Z")

</div>

## I’m having trouble processing data in [Bubble.io](http://Bubble.io) with JavaScript! 🤯

I’m building a [Bubble.io](http://Bubble.io) app and need to do a fairly complex calculation using a Poisson distribution. For efficiency, I have to execute it with Javascript (using the Toolbox).

**My problem:** I’m able to make the calculation and display the result in the console, but I’m stuck getting it into my [Bubble.io](http://Bubble.io) app.

**Here’s what I’m trying to do:**

The result of my calculation is a 7x7 table (49 data points). Basically, it’s an array of arrays, or a list of objects.

- I successfully display this table in the console with console.log (see screenshot).

 ![image](https://us1.discourse-cdn.com/bubble/original/3X/a/b/abd72470b55e47415a15722f0c014521e2648c35.png)

- But I can’t access the data from that table inside [Bubble.io](http://Bubble.io).

**I’m thinking about creating an API system, but I’m not sure where to start.**

**My question:** Has anyone encountered a similar problem? Do you have any suggestions on how to integrate this data into my [Bubble.io](http://Bubble.io) app?

**Any advice is greatly appreciated! 🙏**

**PS:** If you need more information about my calculation or how I’m using the Toolbox, feel free to ask!

thumb\_upthumb\_down

---

<div class="post-metadata">

**Author:** ![adamhholmes](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/adamhholmes/32/100510_2.png) [@adamhholmes](https://forum.bubble.io/u/adamhholmes)\
**Post date:** [October 15, 2024, 10:30pm UTC](https://forum.bubble.io/t/im-having-trouble-processing-data-in-bubble-io-with-javascript/344411/2 "2024-10-15T22:30:03Z")

</div>

Yeah… this is one of Bubble’s _biggest_ limitations…

Although you _can_ work with Custom JavaScript in Bubble (in various ways, including the toolbox plugin), there’s literally no way you can access or use the output data (unless it’s primitive datatypes, or existing Bubble objects) in the Bubble editor…

Except, that is, by outputting that data as a JSON string, and then sending that string, via the API connector, to a backend workflow in your app, only to return it to the page where it was created, whereby it can then be parsed (thanks to the API Connector) into useable data (API data), that can then be accessed in the editor (ridiculous… yes).

So, you’re forced to incur WU cost, and use server bandwidth, just to access basic data (data that should be entirely client-side).

But… that’s just the way it is with Bubble.

So if you need to work with custom JS and non-Bubble objects, this is the way it has to be done.

(It’s actually not that bad… just a bit frustrating that it has to be this way, just to do super simple things like display some object data on a page).

---

<div class="post-metadata">

**Author:** ![tunacardak](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/tunacardak/32/230212_2.png) [@tunacardak](https://forum.bubble.io/u/tunacardak)\
**Post date:** [October 15, 2024, 10:50pm UTC](https://forum.bubble.io/t/im-having-trouble-processing-data-in-bubble-io-with-javascript/344411/3 "2024-10-15T22:50:52Z")

</div>

I need to know more about the flow to suggest a solution, but did you try sending the output via `Toolbox -> JavascripttoBubble`?

---

<div class="post-metadata">

**Author:** ![chad5](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/chad5/32/195650_2.png) [@chad5](https://forum.bubble.io/u/chad5)\
**Post date:** [October 15, 2024, 10:54pm UTC](https://forum.bubble.io/t/im-having-trouble-processing-data-in-bubble-io-with-javascript/344411/4 "2024-10-15T22:54:03Z")

</div>

Get a sample of your json, put it manually in a blank api and initialise.

Put your code in a run js workflow and send it to your bubble to js element using bubble\_fn\_xxx

I output as text and then use a json to bubble things plugin to convert to the api thing you initialised

---

<div class="post-metadata">

**Author:** ![chad5](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/chad5/32/195650_2.png) [@chad5](https://forum.bubble.io/u/chad5)\
**Post date:** [October 15, 2024, 10:55pm UTC](https://forum.bubble.io/t/im-having-trouble-processing-data-in-bubble-io-with-javascript/344411/5 "2024-10-15T22:55:31Z")

</div>

You can also use the jsonata plugin to convert, with the added value of being able to modify the data using jsonata

---

<div class="post-metadata">

**Author:** ![georgecollier](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/georgecollier/32/182327_2.png) [@georgecollier](https://forum.bubble.io/u/georgecollier)\
**Post date:** [October 15, 2024, 10:55pm UTC](https://forum.bubble.io/t/im-having-trouble-processing-data-in-bubble-io-with-javascript/344411/6 "2024-10-15T22:55:50Z")

</div>

> [@chad5](#):
>
> Get a sample of your json, put it manually in a blank api and initialise.

Yes, this is a very good hack that allows you to process JSON types entirely client side without making the API call. Still a pain in the ass but marginally better.

Essentially, you have a plugin element, stick the JSON in there, make the plugin element return your API (data) type, and then you can use it.

---

<div class="post-metadata">

**Author:** ![chad5](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/chad5/32/195650_2.png) [@chad5](https://forum.bubble.io/u/chad5)\
**Post date:** [October 15, 2024, 10:56pm UTC](https://forum.bubble.io/t/im-having-trouble-processing-data-in-bubble-io-with-javascript/344411/7 "2024-10-15T22:56:47Z")

</div>

I use jsonata do do some super conplex data manipulation before bulk creating thing using the bubble data api. Super powerful , I can create 100000 objects in the bubble db within seconds

---

<div class="post-metadata">

**Author:** ![chad5](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/chad5/32/195650_2.png) [@chad5](https://forum.bubble.io/u/chad5)\
**Post date:** [October 15, 2024, 10:57pm UTC](https://forum.bubble.io/t/im-having-trouble-processing-data-in-bubble-io-with-javascript/344411/8 "2024-10-15T22:57:24Z")

</div>

Are you saying you don’t need the json to bubble things converter?

---

<div class="post-metadata">

**Author:** ![adamhholmes](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/adamhholmes/32/100510_2.png) [@adamhholmes](https://forum.bubble.io/u/adamhholmes)\
**Post date:** [October 15, 2024, 11:12pm UTC](https://forum.bubble.io/t/im-having-trouble-processing-data-in-bubble-io-with-javascript/344411/9 "2024-10-15T23:12:27Z")

</div>

> [@tunacardak](#):
>
> I need to know more about the flow to suggest a solution, but did you try sending the output via `Toolbox -> JavascripttoBubble`?

You can only send primitive datatypes (text, numbers, dates, etc.) or Bubble datatypes (custom Datatypes, Option Sets, or Api data) to a Javascript to Bubble element.

There is no way in Bubble to work with non-Bubble objects (aside from doing everything completely in custom code… at which point, there’s little point in using Bubble at all).

---

<div class="post-metadata">

**Author:** ![maximilien.godeau.of](https://avatars.discourse-cdn.com/v4/letter/m/35a633/32.png) [@maximilien.godeau.of](https://forum.bubble.io/u/maximilien.godeau.of)\
**Post date:** [October 16, 2024, 2:29pm UTC](https://forum.bubble.io/t/im-having-trouble-processing-data-in-bubble-io-with-javascript/344411/10 "2024-10-16T14:29:05Z")

</div>

Thanks for your suggestions, I’ll be sure to look into them. I’ve been focusing on the API connector for now, and I’d like to be able to reproduce this schema:

 ![image](https://us1.discourse-cdn.com/bubble/original/3X/d/f/df876c8fc20059f96bb3c2ffc6ce76366845792a.png)

I’m not sure if there’s a simpler way to do this or not, but I need to get the JSON data to use it and perform sums and averages from the results of my calculation.

If you have a specific process with an example, that would be amazing. Thanks in advance! 🙂

---

<div class="post-metadata">

**Author:** ![zelus\_pudding](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/zelus_pudding/32/68250_2.png) [@zelus\_pudding](https://forum.bubble.io/u/zelus_pudding)\
**Post date:** [October 16, 2024, 4:28pm UTC](https://forum.bubble.io/t/im-having-trouble-processing-data-in-bubble-io-with-javascript/344411/11 "2024-10-16T16:28:12Z")

</div>

You’re going to need two things.

1. Initialize an API call in Bubble API Connector that loads the JSON object you’re trying to return to your client (your matrix / list of lists).
2. Create a custom Bubble plugin that returns that list of lists having set it’s return type to “App Type”

**Tackling the first item** is the easiest. Save your object which you’re already `console.logging` to a json file, upload that to your App (to get it available at a URL), and then initialize a Bubble API connector call to the URL of the json file you just uploaded. At this point you have an API call that knows the structure of the data you want to return.

**The second aspect is a little trickier** but is a solved problem in Bubble. In short, in the custom plugin you’re going to have made, you’ll have to massage your lists of lists to have the certain structure that Bubble expects “Bubble API call objects” to be in. Nice folks in the forum have previously created javascript to do this for you which you can [find here](https://github.com/Lottemint/json-to-bubble-object). For discussion on the topic, [see here](https://forum.bubble.io/t/how-to-return-objects-from-plugins-ssa-csa-element-update-element-workflow-actions/165646).
