React JS Tutorial - 06 How to get data from Spotify (playlists example)

Опубликовано: 04 Март 2021
на канале: Carmelle Codes
13k
210

Now that we’ve implemented the Spotify authorization login flow in video 5, let’s get playlist data from the Spotify Web API. This tutorial is not just specific to playlists - this method of calling on the Spotify Web API through an Axios GET request can be applied to any of the data the Spotify Web API offers, such as albums, artists, and what Spotify calls Player (like what the user is currently playing). All you need is the endpoint, proper authentication tokens, and a way to track the network response from Spotify.

Level: Intermediate

0:00 Intro
1:31 Start coding
2:45 npm i axios
3:08 Define useState hooks
4:00 Define useEffect() hook to get tokens
5:11 handleGetPlaylists function
7:22 Test network request to Spotify’s endpoint
8:11 Add proper authorization header to axios GET request
9:30 Manual test our full axios GET request
9:40 401 Explanation
10:46 Demo worked! Let’s display the playlist names
11:18 Explaining network response
11:58 Optional chaining explanation
12:30 Iterate over data items array
13:45 Manual testing again

GitHub Repo Link:

Directions for how to get private playlists: For more info, see Spotify docs for further instruction details. Specifically, try adding various "scopes" to the sample GET request.


Смотрите видео React JS Tutorial - 06 How to get data from Spotify (playlists example) онлайн без регистрации, длительностью 14 минут 02 секунд в хорошем hd качестве. Это видео добавил пользователь Carmelle Codes 04 Март 2021, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 13 тысяч раз и оно понравилось 210 людям.