0
import React, {Component} from 'react';
import ReactDOM from 'react-dom';
import Profile from './Github/Profile.jsx';
class App extends Component{
constructor(props){
super(props);
this.state = {
username: 'TedSean',
userData: [],
userRepos: [],
perPage: 5
}
}
profileData() {
$.ajax({
url: 'https://api.github.com/users/'+this.state.username+'?client_id='+this.props.clientId+'&client_secret='+this.props.clientSecret,
dataType: 'json',
cache: false,
success: function(data){
console.log(data);
}.bind(this),
error: function(xhr, status, err){
alert(err);
}.bind(this)
});
}
componentDidMount() {
this.profileData();
}
render() {
return (
<div>
{this.props.username}
</div>
)
}
}
我想使用AJAX与Github API来获取配置文件数据,但不知道为什么它不工作。任何人都可以解释为什么JSON数据没有得到登录开发工具?AJAX&React:Console.log不起作用?
任何帮助,将不胜感激:)
是阿贾克斯成功? – brk
是Ajax成功。 – Rakzzzz
componentDidMount如何被调用? – user1428716