尝试将 Spotify 推荐与 React 结合使用时出现 400 错误

Getting 400 error when trying to use Spotify recommendations with react

我在尝试使用 Spotify Web Api 和 React 检索推荐时收到 400 个无效请求。我已经让它检索了我正在播放的歌曲,所以我知道 OAuth2 工作正常。

检索推荐的函数是:

    // Scopes
    var scope = 'user-read-private user-read-email user-read-playback-state';

    // Function
    getRecommendations() {
        var data = {
            seed_tracks: [
                'spotify:track:3YSgPxT1T1HroVJxpN2aye',
                'spotify:track:2TxaEF8u2Po2c3RqevD3sd'
            ],
            seed_artists: [
                'spotify:artist:1p2z4hiBCkxfWZ6OvyGBSA',
                'spotify:artist:5SwsSD9zyWaWeVyK9qIW9l'
            ],
            seed_genres: [
                'classical',
                'country'
            ],
        };

        spotifyWebApi.getRecommendations(data).then((response) => {
            this.setState({
                nowPlaying: {
                    test: response.tracks,
                }
            })

        })
    }

知道我做错了什么吗?

我明白了。问题是我的输入 'spotify:artist:1p2z4hiBCkxfWZ6OvyGBSA' 应该只是 '1p2z4hiBCkxfWZ6OvyGBSA' 而不是。