# Import object or array in plugin

**URL:** <https://forum.bubble.io/t/import-object-or-array-in-plugin/165633>\
**Category:** Plugin builders\
**Created:** [August 21, 2021, 2:13pm UTC](https://forum.bubble.io/t/import-object-or-array-in-plugin/165633 "2021-08-21T14:13:55Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![estudio315](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/estudio315/32/93646_2.png) [@estudio315](https://forum.bubble.io/u/estudio315)\
**Post date:** [August 21, 2021, 2:13pm UTC](https://forum.bubble.io/t/import-object-or-array-in-plugin/165633/1 "2021-08-21T14:13:55Z")

</div>

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.

 ![Captura de Pantalla 2021-08-21 a la(s) 10.02.21](https://us1.discourse-cdn.com/bubble/original/3X/2/3/230fd2d897e12dbcd9e6302fb9c0a52a09ce26ef.png)

---

<div class="post-metadata">

**Author:** ![jared.gibb](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/jared.gibb/32/123329_2.png) [@jared.gibb](https://forum.bubble.io/u/jared.gibb)\
**Post date:** [August 21, 2021, 3:49pm UTC](https://forum.bubble.io/t/import-object-or-array-in-plugin/165633/2 "2021-08-21T15:49:43Z")

</div>

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

[https://vimeo.com/590273642](https://vimeo.com/590273642)

###### 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’

---

<div class="post-metadata">

**Author:** ![estudio315](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/estudio315/32/93646_2.png) [@estudio315](https://forum.bubble.io/u/estudio315)\
**Post date:** [August 21, 2021, 4:05pm UTC](https://forum.bubble.io/t/import-object-or-array-in-plugin/165633/3 "2021-08-21T16:05:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![estudio315](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/estudio315/32/93646_2.png) [@estudio315](https://forum.bubble.io/u/estudio315)\
**Post date:** [August 21, 2021, 4:06pm UTC](https://forum.bubble.io/t/import-object-or-array-in-plugin/165633/4 "2021-08-21T16:06:35Z")

</div>

actions\* no shared\*

---

<div class="post-metadata">

**Author:** ![jared.gibb](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/jared.gibb/32/123329_2.png) [@jared.gibb](https://forum.bubble.io/u/jared.gibb)\
**Post date:** [August 21, 2021, 4:32pm UTC](https://forum.bubble.io/t/import-object-or-array-in-plugin/165633/6 "2021-08-21T16:32:45Z")

</div>

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

check it out here!

> [@How to return objects from plugins (SSA, CSA, Element Update & Element Workflow Actions)](http://forum.bubble.io/t/how-to-return-objects-from-plugins-ssa-csa-element-update-element-workflow-actions/165646):
>
> This stumps so many of us when we first start with the plugin editor that I wanted to make a couple quick videos to demonstrate returning an object from your plugin. Video 1: Returning an object from a server-side action [https://vimeo.com/590273642](https://vimeo.com/590273642) – those notes I was writing are below. https://api.thecatapi.com/v1/images/search Getting an object back from the server side actions seems impossible at first but it actually really easy. Let’s start by creating a new plugin! We will start …

> [@estudio315](#):
>
> 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.

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

---

<div class="post-metadata">

**Author:** ![estudio315](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/estudio315/32/93646_2.png) [@estudio315](https://forum.bubble.io/u/estudio315)\
**Post date:** [August 21, 2021, 4:41pm UTC](https://forum.bubble.io/t/import-object-or-array-in-plugin/165633/8 "2021-08-21T16:41:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![estudio315](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/estudio315/32/93646_2.png) [@estudio315](https://forum.bubble.io/u/estudio315)\
**Post date:** [August 21, 2021, 4:42pm UTC](https://forum.bubble.io/t/import-object-or-array-in-plugin/165633/9 "2021-08-21T16:42:24Z")

</div>

Will the posts be deleted in 1 hour?

---

<div class="post-metadata">

**Author:** ![jared.gibb](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/jared.gibb/32/123329_2.png) [@jared.gibb](https://forum.bubble.io/u/jared.gibb)\
**Post date:** [August 21, 2021, 4:45pm UTC](https://forum.bubble.io/t/import-object-or-array-in-plugin/165633/10 "2021-08-21T16:45:35Z")

</div>

Nope. They’ll stay there!

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

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.

---

<div class="post-metadata">

**Author:** ![estudio315](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/estudio315/32/93646_2.png) [@estudio315](https://forum.bubble.io/u/estudio315)\
**Post date:** [August 21, 2021, 5:21pm UTC](https://forum.bubble.io/t/import-object-or-array-in-plugin/165633/11 "2021-08-21T17:21:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jared.gibb](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/jared.gibb/32/123329_2.png) [@jared.gibb](https://forum.bubble.io/u/jared.gibb)\
**Post date:** [August 21, 2021, 5:30pm UTC](https://forum.bubble.io/t/import-object-or-array-in-plugin/165633/12 "2021-08-21T17:30:21Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![estudio315](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/estudio315/32/93646_2.png) [@estudio315](https://forum.bubble.io/u/estudio315)\
**Post date:** [August 22, 2021, 3:31am UTC](https://forum.bubble.io/t/import-object-or-array-in-plugin/165633/13 "2021-08-22T03:31:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jared.gibb](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/jared.gibb/32/123329_2.png) [@jared.gibb](https://forum.bubble.io/u/jared.gibb)\
**Post date:** [August 22, 2021, 10:24am UTC](https://forum.bubble.io/t/import-object-or-array-in-plugin/165633/14 "2021-08-22T10:24:01Z")

</div>

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)
```

---

<div class="post-metadata">

**Author:** ![estudio315](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/estudio315/32/93646_2.png) [@estudio315](https://forum.bubble.io/u/estudio315)\
**Post date:** [August 22, 2021, 12:49pm UTC](https://forum.bubble.io/t/import-object-or-array-in-plugin/165633/15 "2021-08-22T12:49:10Z")

</div>

Thanks I

Thank you I will try it !!!

---

<div class="post-metadata">

**Author:** ![jared.gibb](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/jared.gibb/32/123329_2.png) [@jared.gibb](https://forum.bubble.io/u/jared.gibb)\
**Post date:** [August 22, 2021, 12:58pm UTC](https://forum.bubble.io/t/import-object-or-array-in-plugin/165633/16 "2021-08-22T12:58:13Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![estudio315](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/estudio315/32/93646_2.png) [@estudio315](https://forum.bubble.io/u/estudio315)\
**Post date:** [August 23, 2021, 7:36pm UTC](https://forum.bubble.io/t/import-object-or-array-in-plugin/165633/17 "2021-08-23T19:36:11Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![jared.gibb](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/jared.gibb/32/123329_2.png) [@jared.gibb](https://forum.bubble.io/u/jared.gibb)\
**Post date:** [August 23, 2021, 8:43pm UTC](https://forum.bubble.io/t/import-object-or-array-in-plugin/165633/18 "2021-08-23T20:43:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![estudio315](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/estudio315/32/93646_2.png) [@estudio315](https://forum.bubble.io/u/estudio315)\
**Post date:** [August 23, 2021, 8:45pm UTC](https://forum.bubble.io/t/import-object-or-array-in-plugin/165633/19 "2021-08-23T20:45:28Z")

</div>

gracias , entonces te tendré considerado, ya que no logró aplicar las tareas que me diste 😂 🤣
