spotify-web-api-node
spotify-web-api-node copied to clipboard
WebapiError with api.play
Please, can you provide a sample to play a music or playlist?
I´m getting this error in the play method
WebapiError {name: "WebapiError", message: "Not Found", statusCode: 404}
When I try this:
const auth = require('spotify-personal-auth')
const SpotifyWebApi = require('spotify-web-api-node')
auth.config({
clientId: 'aaaaaaaaaa'
clientSecret: 'bbbbbbbbb'
scope: ['user-modify-playback-state', 'user-top-read'],
path: './tokens.json',
redirectUri: 'http://localhost:8888/redirect',
})
const api = new SpotifyWebApi()
auth.token()
.then(([token, refresh]) => {
api.setAccessToken(token)
api.setRefreshToken(refresh)
return api.getMyTopTracks()
})
.then((data) => api.play({ uris: ['spotify:track:6KBsivP3Of4z2x6uNMAyE3'] }))
.catch(console.log)
i think you need to pass just the uri, trim off spotify & track using .split(':')[2]
edit: this doesnt work for me either. I am not sure how to fix this.
Did you find any way to make this work? Also, did you have to first connect the Spotify player using the SDK.