简体   繁体   English

“ WebapiError”是什么意思?

[英]What does “WebapiError” mean?

I'm working on Spotify Web App that just retrieves KD Rusha Top Albums trying to used Client ID, Artist ID to fetch only KD Rusha top album releases on his Spotify. 我正在使用Spotify Web App,该Web App只检索试图使用Client ID和Artist ID的KD Rusha热门专辑,以仅在他的Spotify上获取KD Rusha热门专辑发行。 I'm using an npm package called spotify-web-api-node . 我正在使用一个名为spotify-web-api-node的npm包。

Error Message 错误信息 在此处输入图片说明

import React from 'react';
import SpotifyWebApi from 'spotify-web-api-node';
require('dotenv').config();

// My Steps: //
// GO TO SPOTIFY AND GETTING KD RUSHA TOP ABLUMS lIMIT TO 9 SONGS
// WHEN YOU CLICK ON TOP OF THE ABLUMS A PLAY BUTTON ICON WILL SHOW TO INDICATE THAT YOU CAN PLAY 30 SECONDS OF SONG

const spotifyApi = new SpotifyWebApi({
  clientId : 'here where client id',
  clientSecret : 'here where client secret',
  redirectUri : 'http://www.localhost.com/callback'
});

export default class SpotifyComponent extends React.Component {

  componentDidMount() {
    window.setTimeout(() => {
      this.fetchData();
    }, 3000)
  }

 fetchData() {//Its Fetch Artist Albums The Spotify Date
   spotifyApi.getArtistAlbums('5JLWikpo5DFPqvIRi43v5y', {limit: 9})
     .then(function(data) {
       return data.body.albums.map(function(a) { return a.id; });
     })
     .then(function(albums) {
       return spotifyApi.getAlbums(albums);
     }).then(function(data) {
       console.log(data.body);
   });
 }

  render(){
    return(
      <div className='spoify-container'>
        <img src="{image.albums}" alt="kdrusha-albums" />
      </div>
    );
  }
}

The statusCode you're getting back is 401 Unauthorized which means there's a problem with the credentials. 您返回的statusCode为401 Unauthorized ,这意味着凭据存在问题。 Make sure you're initializing clientId and clientSecret correctly. 确保正确初始化了clientIdclientSecret

You're getting a 401 unauthorized error. 您收到401未经授权的错误。 Something must be wrong with the way your authenticating with the API. 使用API​​进行身份验证的方式一定存在问题。 According to Spotify's docs: https://developer.spotify.com/web-api/user-guide/#response-status-codes 根据Spotify的文档: https : //developer.spotify.com/web-api/user-guide/#response-status-codes

401 Unauthorized - The request requires user authentication or, if the request included authorization credentials, authorization has been refused for those credentials. 401未经授权-请求需要用户认证,或者,如果请求中包含授权凭证,则拒绝这些凭证的授权。

Check your credentials. 检查您的凭据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM