laravelにのっかっているVue.jsのコンポーネントの中に、spotifyのAPIを記載してアルバムデータの取得を実行してみました。
すると、取得しに行っている側の自分で書いているアプリが戻ってきているようです。
axiosを初めて使ったので、何かを勘違いしているのかもしれません。
どうやったらアルバムデータが戻ってくるのでしょう??
【追加情報】
クライアントID/secretはspotifyにアプリを登録して取得したもの、
パラメータについては
https://beta.developer.spotify.com/console/get-several-albums/
のサンプルを持ってきています。
ターミナルでcurlで試してみたり、↑URLのspotify consoleにこちらで作成したトークン入れて試してみる分には、欲しい結果が戻ってきているのですが、、、
【↓APIを取得するために記入したもの。】
javascript
1 const cdata = { 2 client_id: client_idが入る, 3 client_secret: client_secretが入る, 4 }; 5 6 export default { 7 mounted: function () { 8 this.getArts() 9 }, 10 methods: { 11 getArts(){ 12 var AuthStr = 'Bearer '+window.btoa(cdata.client_id+':'+cdata.client_secret); 13 14 axios.get({ 15 baseURL: 'https://api.spotify.com/v1/albums', 16 params : { 17 'ids': '382ObEPsp2rxGrnsizN5TX', 18 'market': 'ES' 19 }, 20 headers: { 21 Authorization: AuthStr, 22 }, 23 timeout: 1000, 24 }) 25 .then(function(r){ 26 console.log(r); 27 }) 28 .catch(function(error) { 29 console.log(error); 30 }); 31 } 32 } 33 }
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/04/01 18:38 編集