81
rated 0 times
[
82]
[
1]
/ answers: 1 / hits: 29241
/ 8 Years ago, wed, august 3, 2016, 12:00:00
I have this function:
getUserData() {
fetch(this.props.apiUrl + this.state.username + '?client_Id=' + this.props.clientId + '&client_secret=' + this.props.clientSecret)
.then(function(response) {
var data = response.json();
this.setState({
userData: data
});
console.log(this.state.userData);
}.bind(this))
.catch(function(error) {
this.setState({
username: null
});
console.log(error)
}.bind(this))
}
Which returns this in the console:
Promise {[[PromiseStatus]]: pending, [[PromiseValue]]: undefined}
proto
[[PromiseStatus]] : resolved
[[PromiseValue]] : Object
avatar_url : https://avatars.githubusercontent.com/u/
login : hello world
.
.
.
I need to access the name/value pairs in the object but I can't get to them. I'm assuming I need to take one extra step after I convert the response to json but can't figure it out. If anyone could help it would be greatly appreciated!
More From » reactjs