|
1 |
| -var SpotifyWebApi = require('../'); |
| 1 | +const SpotifyWebApi = require('../'); |
2 | 2 |
|
3 | 3 | /**
|
4 |
| - * This example demonstrates adding tracks, removing tracks, and replacing tracks in a playlist. At this time of writing this |
5 |
| - * documentation, this is the available playlist track modification features in the Spotify Web API. |
| 4 | + * This example demonstrates adding tracks, removing tracks, and replacing tracks in a playlist. At the time of writing this |
| 5 | + * documentation, this is the available playlist track modification feature in the Spotify Web API. |
6 | 6 | *
|
7 | 7 | * Since authorization is required, this example retrieves an access token using the Authorization Code Grant flow,
|
8 |
| - * documented here: https://developer.spotify.com/spotify-web-api/authorization-guide/#authorization_code_flow |
| 8 | + * documented here: https://developer.spotify.com/documentation/general/guides/authorization-guide/#authorization-code-flow |
9 | 9 | *
|
10 | 10 | * Codes are given for a set of scopes. For this example, the scopes are playlist-modify-public.
|
11 | 11 | * Scopes are documented here:
|
12 |
| - * https://developer.spotify.com/spotify-web-api/using-scopes/ |
| 12 | + * https://developer.spotify.com/documentation/general/guides/scopes/ |
13 | 13 | */
|
14 | 14 |
|
15 |
| -/* This code is hardcoded. For a working implementation, the code needs to be retrieved from the user. See documentation about |
16 |
| - * the Authorization Code flow for more information. |
| 15 | +/* Obtain the `authorizationCode` below as described in the Authorization section of the README. |
17 | 16 | */
|
18 |
| -var authorizationCode = |
| 17 | +const authorizationCode = |
19 | 18 | '<insert authorization code with playlist-modify-public scope>';
|
20 | 19 |
|
21 | 20 | /**
|
22 |
| - * Set the credentials given on Spotify's My Applications page. |
23 |
| - * https://developer.spotify.com/my-applications |
| 21 | + * Get the credentials from Spotify's Dashboard page. |
| 22 | + * https://developer.spotify.com/dashboard/applications |
24 | 23 | */
|
25 |
| -var spotifyApi = new SpotifyWebApi({ |
| 24 | +const spotifyApi = new SpotifyWebApi({ |
26 | 25 | clientId: '<insert client id>',
|
27 | 26 | clientSecret: '<insert client secret>',
|
28 | 27 | redirectUri: '<insert redirect URI>'
|
29 | 28 | });
|
30 | 29 |
|
31 |
| -var playlistId; |
| 30 | +let playlistId; |
32 | 31 |
|
33 | 32 | // First retrieve an access token
|
34 | 33 | spotifyApi
|
@@ -81,6 +80,5 @@ spotifyApi
|
81 | 80 | console.log('Ok. Tracks replaced!');
|
82 | 81 | })
|
83 | 82 | .catch(function(err) {
|
84 |
| - console.log(err.message); |
85 |
| - console.log('Something went wrong!'); |
| 83 | + console.log('Something went wrong:', err.message); |
86 | 84 | });
|
0 commit comments