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.
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’
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
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)
Buen día 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