reactjs - Consume RESTful data with React and Axios -
how can retrieve data https://api.github.com/search/users?q=jason , render in react? tried like:
constructor(){ this.state = { data: [] }; } componentdidmount(){ axios.get("https://api.github.com/search/users?q="+_searchterm) .then(res => { this.setstate({ data: _.values(res.data.items) }) }); } render() { const listproducts = this.state.data.map((product) => <li key={product.tostring()}>{product}</li> ); return ( <div> <ul>{listproducts}</ul> </div> ); } but didn't work. error message:
unhandled rejection (invariant violation): objects not valid react child (found: object keys {login, id, avatar_url, gravatar_id, ...). if meant render collection of children, use array instead or wrap object using createfragment(object) react add-ons.
so guess have convert response array. not sure how it.