Created
September 20, 2018 03:14
-
-
Save DragonFyZex/ea112ae36a0a768b23415b934cf34c95 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
import axios from 'axios'; | |
class Reddit extends React.Component | |
{ | |
state = { | |
posts: [], | |
coolthing: [] | |
} | |
componentDidMount() | |
{ | |
axios.get(`https://www.reddit.com/r/dota2.json`) | |
.then(res => { | |
const posts = res.data.data.children.map(obj=> obj.data); | |
this.setState({posts}); | |
}) | |
} | |
render() { | |
const used = []; | |
return( | |
<div> | |
{this.state.posts.map(post => ( | |
<li key={post.id}> {post.preview.images[0].id} </li> | |
))} | |
</div> | |
) | |
} | |
} | |
ReactDOM.render(<Reddit/>, document.getElementById('root')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment