• 771 Topics
  • 2,514 Replies

771 Topics

Get user id

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