Answered

Is it possible to use window.location.pathname to get Miro board path while using REST API?

  • 29 October 2020
  • 1 reply
  • 558 views

Userlevel 2
Badge +3

Hi,

I’m using Miro REST API in the form of a sidebar, I’m trying to export data to a external database and would like to mark each dataset with its corresponding miro board ID from the board url like this one for example: https://miro. com/app/board/hereistheboardid/

I’m trying to do this by calling window.location.pathname.split('/') from which I then obtain an array of paths in the link. Unfortunately the paths that I get returned back are ones from my server where I keep the code to my miro REST API  

Outlined in blue is my sidebar, from which the url path gets returned, but in the red there is underlined the actual window url / location which I believe it should return. Any ideas how to get the miro board URL via my REST API / webplugin?

icon

Best answer by Daniela Gavidia 3 November 2020, 11:29

View original

1 reply

Userlevel 4
Badge

Hello Sami,

 

If you want to get the id of the Miro board, you could use the SDK. The board object provides information about the current board. You would call it like this:
 

await miro.board.info.get()

See:

My Board Info

Calling miro.board.info.get() returns a promise that resolves to a BoardInfo object:
https://developers.miro.com/docs/interface-iboardinfocommands#section-get

https://developers.miro.com/docs/interface-iboardinfo

 

You can get only the board id like this:

(await miro.board.info.get()).id

I hope this helps.

 

Kind regards.

 

Daniela

 

Reply