每次我单击登录按钮时,它会将我重定向到“ https://www.themoviedb.org/authenticate/undefined
重定向时,我在控制台中收到此错误 未知的数据源传输类型为“ json”。 验证页面上的Kendo UI之后是否包含此类型的注册脚本。
当我控制台日志结果时,我收到令牌请求,只是没有将其添加到URL中。
这是我的代码:
import React, { Component } from 'react';
import $ from 'jquery';
const movieApiKey = process.env.REACT_APP_MOVIEAPI;
class getRequestToken extends Component {
constructor(props) {
super(props)
this.state = {}
this.getToken()
}
getToken() {
console.log("Get request token from movieDB")
const UrlString = "https://api.themoviedb.org/3/authentication/token/new?api_key=" + movieApiKey
$.ajax({
type: "POST",
dataType: 'jsonp',
url: UrlString,
success: (tokenResults) => {
console.log("request token succesful")
console.log(tokenResults);
const results = tokenResults.request_token
console.log(results)
},
error: (xhr, status, err) => {
console.log("failed to get token")
}
})
}
render() {
return (
<div className="login">
<a href={`https://www.themoviedb.org/authenticate/${this.results}`}>
<button className="btn btn-outline-success" onClick={this.getToken} >Log In</button>
</a>
</div>
)
}
}
export default getRequestToken