現在、現在のトラックを取得するためにKD Rushaを取得しようとしています。彼のウェブサイトに表示し、誰かが歌のイメージの上にマウスを乗せて再生すると再生ボタンを表示します。私はここで間違って何をしていますか?Spotify APIによるアーティストトラックデータの返送エラーが不正
マイステップ:
- Spotifyは上のKD Rushaトップアルバムのために取得したいです。
- 9トラックに制限します。
各トラックの上部に再生ボタンを追加して30秒間再生します。
アーティストID
https://api.spotify.com/v1/artists/{id}
これは完全に間違っているかもしれませんが、あなたのコードのおかげで誰もまだあなたに答えていないと私は非常によく似た問題の解決策を見つけたので、私に401 (Unauthorized)
import React from 'react'; require('dotenv').config(); export default class SpotifyComponent extends React.Component { constructor(props){ super(props); this.state = { artist: null, }; } componentWillMount() { var request = new Request('https://api.spotify.com/v1/artists/5JLWikpo5DFPqvIRi43v5y', { method: 'GET', headers: new Headers({ 'Accept': 'application/json', 'Content-Type': 'text/plain', 'Authorization': 'Bearer <big blob of token here>' }) }); fetch(request)// fetch the Spotify date from KD Rusha Account .then((response) => { var result = response.json() this.setState({// State artist albums albums: result, selectedTrack: [0] }); console.log(response.json()); if (response.status >= 400) { throw new Error("Bad response from server"); } return response.json(); }); } render(){ return( <section className="spotify-cantainer"> <img src="{albums}" alt="kdrusha" /> </section> ); } }
正しいトークンをお持ちですか?あなたはそれをずっと前に要求しましたか?それは期限が切れている可能性があります – taylorc93
あなたの本当のAPIトークンを投稿することはお勧めしません:) –