doctororange
doctororange

Reputation: 11810

How can I retrieve a Trello Board's shortLink from a card page?

I'm making a Google Chrome extension for Trello, and want to get the shortLink of the current Board, while viewing a Card URL.

For example:

This card https://trello.com/c/v9eqAHMX/20-api-documentation

Belongs to this board https://trello.com/b/nPNSBZjB/trello-resources

If the current page is the board then I can extract the shortLink (nPNSBZjB in this case) from window.location.pathname. But if the current page is a card, is it possible to retrieve the board's shortlink using javascript?

Keeping track of the last board URL that was visited works in most cases, but not when a user lands directly on the card URL (without going via the board).

Thanks.

Upvotes: 3

Views: 2299

Answers (1)

Aaron Dufour
Aaron Dufour

Reputation: 17535

Your best bet will be to use the card's shortLink to make a few API requests. Using this route, you can get the board's long id from the card's shortLink. If you need the shortLink (the id would, for most purposes, suffice), you can use the id and this route.

There are ways to do it synchronously, but they will be very fragile and prone to breaking on client updates, so I would not recommend them.

Upvotes: 1

Related Questions