Advertisement
Guest User

Untitled

a guest
Feb 3rd, 2018
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. findUserId() {
  2.   if(accessToken === undefined) {
  3.     this.getAccessToken();
  4.   }
  5.   console.log(accessToken);
  6.   let userId;
  7.   return fetch(`https://api.spotify.com/v1/me`, {'Authorization': `Bearer ${accessToken}`}}
  8.     ).then(response => {return response.json()}
  9.     ).then(jsonResponse => {
  10.         return jsonResponse.id;
  11.     });
  12. }
  13.  
  14. // use as
  15. findUserId().then(id => {
  16.   console.log(id)
  17. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement