Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class App extends Component {
- render() {
- console.log(this.props);
- return (
- <div id="root">
- <div className="main">
- <Header />
- <Timeline login={this.props.params.login}/>
- </div>
- </div>
- );
- }
- }
- export default class Timeline extends Component {
- constructor() {
- super();
- this.state = {fotos: []};
- }
- componentDidMount() {
- let urlPerfil;
- if(this.props.login === undefined) {
- urlPerfil = `http://localhost:8080/api/fotos?X-AUTH-TOKEN=${localStorage.getItem('auth-token')}`;
- } else {
- urlPerfil = `http://localhost:8080/api/public/fotos/${this.props.login}`;
- }
- fetch(urlPerfil)
- .then(response => response.json())
- .then(fotos => {
- this.setState({fotos: fotos});
- });
- }
- render(){
- return (
- <div className="fotos container">
- {
- this.state.fotos.map(foto => <FotoItem key={foto.id} foto={foto} />)
- }
- </div>
- );
- }
- }
Add Comment
Please, Sign In to add comment