【问题标题】:Getting 400 error when trying to use Spotify recommendations with react尝试将 Spotify 推荐与 React 一起使用时出现 400 错误
【发布时间】:2020-03-23 11:47:22
【问题描述】:

我在尝试使用带有 react 的 Spotify Web Api 检索推荐时收到 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,
                }
            })

        })
    }

知道我做错了什么吗?

【问题讨论】:

    标签: javascript node.js reactjs spotify


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2011-01-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-28
      • 2012-03-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多