React native 尝试请求Spotify访问令牌时获取状态415错误
我正在尝试获取Spotify的客户端凭据流访问令牌,但下面的代码仅给出状态错误415。我正在使用React Native/axiosReact native 尝试请求Spotify访问令牌时获取状态415错误,react-native,axios,spotify,React Native,Axios,Spotify,我正在尝试获取Spotify的客户端凭据流访问令牌,但下面的代码仅给出状态错误415。我正在使用React Native/axios makeSPYReq = (id) => { axios.post('https://accounts.spotify.com/api/token', { data: { grant_type: 'client_credential
makeSPYReq = (id) => {
axios.post('https://accounts.spotify.com/api/token',
{
data: {
grant_type: 'client_credentials',
'Content-Type': 'application/x-www-form-urlencoded',
}
},
{
headers: {
'Authorization': `Basic ${id}`
}
})
.then((res)=>console.log(res))
.catch(e => {
console.log(e);
});
}
componentDidMount() {
const encodedString = new Buffer(`${SPY_CLIENT}:${SPY_SECRET}`).toString('base64');
this.makeSPYReq(encodedString)
}
我在试图找出错误可能在哪里时遇到了问题。我想我做的一切都是按照医生说的:这是相关的吗:。如果你在客户端执行这段代码,那么这就是你的答案,我想这就是问题所在。非常感谢。您知道我如何为此目的将节点服务器环境设置为React Native吗?。任何提示或链接都将不胜感激。我从未使用过react,也不知道它是如何工作的。也许您可以设置一个简单的express服务器。要从前端调用的API?我不确定。干杯我去看看。