0

I'm building a Chrome extension that I plan to use as components library for Bubble.io

The principle is easy, I'm storing components in my Bubble.io app database, and people will be able to paste those elements to paste them into their app.

To handle access to the DB, Authentication, etc. I've chosen to use an embed of my app in my extension. In order to make it work, I need to modify the user local storage (precisely, the key "bubble_element_clipboard") in order to inject the element's data.

I managed to do that through the postMessage API method. The data changes, but it is not saved under the right format (see screenshots below).

I know it is possible to create such extension because some already exist.

I just can't understand why Chrome isn't parsing the JSON I'm sending it.

How to fix that?

Screenshot 1 : How the data is supposed to look enter image description here

Screenshot 2 : How my data actually looks enter image description here

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
  • You need to convert the string value back into an object after you retrieve it from localstorage. `JSON.parse()` https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse – Daniel Beck Aug 01 '23 at 16:59
  • Looks like you're JSON-stringifying a JSON string, but in the absence of a [mre] it's hard to say more. – jonrsharpe Aug 01 '23 at 16:59

0 Answers0