found an answer, can’t delete the question for some reason
Hi Sami,
You were almost there - calling miro.board.widgets.get() will return a promise, that when resolved, provides a full list of widgets on the board.
Hope this answers your question!
Hi Viktor,
Yes I just found out about it, thanks a lot for your help.
Hi Sami,
You were almost there - calling miro.board.widgets.get() will return a promise, that when resolved, provides a full list of widgets on the board.
Hope this answers your question!
Hi Viktor,
calling miro.board.widgets.get() has worked for me for the past 2 days returning all widgets on board with this syntax:
let allWidgets = miro.board.widgets.get().then(function() {
console.log("widgets on board: ", allWidgets)
})
or this for only shapes
let allWidgets = miro.board.widgets.get({
“type” : “SHAPE”
}).then(function() {
console.log("widgets on board: ", allWidgets)
})
but from today morning i’m only getting this error in both cases: Uncaught TypeError: Cannot read property 'widgets' of undefined . Is my syntax wrong or has something that you know of changed on miros side?
Thanks for your time.
Hi @Sami Ljimari
miro.board.widgets.get() is an asynchronous function and returns a promise, but not an array of widgets. You need to either await the call, or use an argument in the .then() callback, like this:
let allWidgets = await miro.board.widgets.get()
console.log("widgets on board: ", allWidgets)
or this for only shapes
miro.board.widgets.get({
“type” : “SHAPE”
}).then(function(allWidgets) {
console.log("widgets on board: ", allWidgets)
})
Hope this helps you.