Forum Academy Marketplace Showcase Pricing Features

Import object or array in plugin

Hello, I need help, I know that this can be easy for many of you, but I am starting to turn around.

I am building my first plugin and I am stuck in a step.

I am interested to access the information that I have in algolia.

But, I have a question, I already managed to connect, bring info from Algolia and everything easy from there there is already a lot of documentation. But on the bubble side, it has been difficult for me to understand the next step, which is to take the information of the object and be able to see it in some element and that is not console.log (the one that shows me that it brings it)

I did the @copilot course, but everything is understood perfectly, but it is not explained when it is an object or JSON or array, how I pass the info for example to a state?.

When I occupy instance.publishState (); it tells me this, “Trying to send an invalid array to Bubble”

thanks from chile

In general, I don’t understand how to work with objects and pass them to a state.

Check out my non-edited video demonstrating this exact idea!

this was shot while riding in the back of a minivan on my way home from vacation. excuse the pauses, no voice over, and general feeling of ‘yeah the details are there but the video sucks’
2 Likes

Thanks for the prompt response and help, I am not an expert, but I understand some of the documentation and it may be that I am applying it wrong.

The example that you show is done in the api section. I’m in the elements section.

and you occupy the shares.

So I don’t know if we are talking about the same thing.

What I did is bring the algolia api data from elements.

When doing the search it brings me an object (I think), and that object I can see in the console.log (), but I can’t bring it to a state.

Sorry for how messy my explanation is.

And thank you very much for your help, even if it does not come with audio, it is understood what you do.

actions* no shared*

Hey! You’re right, i hadn’t read through that clearly so what i did was make another video!

check it out here!

You’ll define the state as an object using the API connector section of the plugin. It’s a hack to make new data types. You must create your data type to return the object in the state.

You set the exposed state to be the data type (or data model) and now you can publish your object as you’d like

1 Like

Thanks, I’ll check it to see if I understand

Will the posts be deleted in 1 hour?

Nope. They’ll stay there!

I’d have recorded a 4th video but I am riding in a car and my laptop died! :sob:

How do you have your exposed state set?

One hard rule here: if you haven’t defined the object model in the api connector, you simply can’t return an object from the element side.

I say it, because it tells me that if flags are not put, the posts are deleted in 1 hour, it seems that you marked something Thanks for the help

Sorry. I had deleted a post. Instead of several posts, it’s generally better to put them together when it’s all part of 1 response.

I was just trying to keep the information grouped together. Sorry for the confusion!

I think we talk about different things, I share a video so that my idea is understood

I understand fully what you’re asking here.

The issue is, you are trying telling the plugin editor your exposed state is a string when you are in fact passing it an array of objects. The editor is not smart enough to infer the object model.

You could publish several lists of values like this

let list1, list2
hits.forEach( elm => {
   list1.push(elm.property1)
   list2.push(elm.property2)
})


instance.publishState(‘list of strings 1’, list1)
instance.publishState(‘list of strings 2’, list2)

Or if you follow the videos I shared and define your response model in the api editor

eg

{
“Property 1”:””,
“Property 2”:””
}

Return to the element screen and create an input property to be “app type”

Set an exposed state to be that app type that you set in the previous step

In your app editor, you set the input field on the element to be the api response you defined in the plugin

Then you could use a piece of code like to to publish the object as a list

let objectArray
    hits.forEach( elm => {
       objectArray.push({
           “_p_Property 1”: elm.property1,
           “_p_Property 2”: elm.property2
            })
      
    })

instance.publishState(‘objectArrayOut’, objectArray)

Thanks I

Thank you I will try it !!!

If you’re still not getting it, and would be interested in booking a quick coaching session I could walk you through the process! ¡Avísame!

1 Like

gracias, no se como estar tu español, ¿cual es el valor de la sesión?

Thank you, I don’t know how to be your Spanish, what is the value of the session?

Buen día :wave: por sesiones de entrenamiento cobro $ 35 por hora. Estudie español para tres años en universidad. Mi lengua materna es inglés pero todavía, hasta hoy en día, práctico mi español cuando pueda

gracias , entonces te tendré considerado, ya que no logró aplicar las tareas que me diste :joy: :rofl:

1 Like