Skip to main content

Hi,

I have tried a few ways to get the current user id, but I always encounter a error in one way or another. What is the most basic way to get a user id? So far I have mainly tried this:

 

async function getUser() {

        const proxyurl = "https://cors-anywhere.herokuapp.com/" // getting cors error without this

        const url = "https://api.miro.com/v1/users/me"

 

        const options = {

            "method": "GET",

            "headers": {

                “Authorization”: `Bearer ${token}`,

                "Content-Type": "application/json"

            }

        }

 

        fetch(proxyurl + url, options)

        .then(response => {

        console.log(response)

        })

        .catch(err => {

        console.error(err)

        })

    }

I’m currently getting error 401 “Not Authorized”

I’ve seen a few discussions in here about a direct miro dot command that can get the user id but can’t find it anywhere in the documentation. Will be thankful for any suggestions as I ran out of ideas of what to try or where to search anymore

Hi Sami,

 

Please use `miro.currentUser.getId()` to acquire an id of the current user. Please note, that this method returns a promise.

 

Hope this helps.


Hi Viktor,

Yes this solved my issue. Thanks a lot


Reply