Answered

Use case for miro.board.widget.update() with multiple id's

  • 26 May 2021
  • 4 replies
  • 74 views

Userlevel 2
Badge +6

Hi, I’m referring to this command https://developers.miro.com/docs/interface-iboardwidgetscommands#section-update I’m currently using it with single id’s but since it says there is a option to call it with multiple id’s I’d like to utilize this, since I’m exepriencing board freeze / syncing with higher volumes of requests made to the API. I can’t see a example on how to utilize with for example a array of id’s.

 

What I have been using so far:

await miro.board.widgets.update({

                    "id" : widgetID2,

                    "clientVisible" : false

                })

 

Tried replacing my widgetID2 variable with a array but the API returned “Wrong argument passed to miro.board.widgets.update(widgets: {id: string; [index: string]: any}[]).” 

 

I’m experiencing syncing times of up to 1 minute of the board when sending lets say 100 requests to the API to make 100 widgets invisible and want to prevent this ofcourse.

icon

Best answer by Max Harper 26 May 2021, 23:11

@Sami Ljimari 

Make an array around/of the full widget object(s) separated by commas. 
 

await miro.board.widgets.update(

   [

                {    "id" : widgetID1,

                    "clientVisible" : false

                },

                {    "id" : widgetID2,

                    "clientVisible" : false

                }

    ]

)
 

 

that should do the trick. 

View original

4 replies

Userlevel 7
Badge +11

@Sami Ljimari 

Make an array around/of the full widget object(s) separated by commas. 
 

await miro.board.widgets.update(

   [

                {    "id" : widgetID1,

                    "clientVisible" : false

                },

                {    "id" : widgetID2,

                    "clientVisible" : false

                }

    ]

)
 

 

that should do the trick. 

Userlevel 2
Badge +6

@Max Harper 

Thanks for the response, I was thinking of how to execute this since I don’t know the id’s ahead of time and they are instead added by user when my app is running. I tried adding them in a loop into a JSON object like so:

JSONWidgetList = [...JSONWidgetList,{"id":widgetID, "clientVisible" : true}]

and call the method like so:

await miro.board.widgets.update({

        JSONWidgetList

    })

 

But still get the same error, any idea how I could achieve this when I don’t know the amount of widgets or their ID’s ahead of time?

Userlevel 2
Badge +6

My bad, it was a syntax issue on my side with extra pair of {} brackets, Thanks again Max, marking your comment as answer

Userlevel 2
Badge +6

.

Reply