Jhead45
4/27/2018 - 12:15 AM

first chirp attempt (not working)

issue with map in full stack chirp

import React, { Component } from 'react';
import { render } from 'react-dom';
import "isomorphic-fetch";


class Chirp extends Component {

    constructor(props) {
        super(props);
        this.state = { text: []};
    }

    componentDidMount() {
        const url = '/api/chirps'

        fetch(url)
          .then(result => result.json())
          .then(text => {
            let keys = Object.keys(text);
            for (let i of keys) { 
                if (i !== 'nextid'){
                    this.setState(text[i]);
                    console.log(this.state);
                }
            }
        })
      
    }
    render() {
        return (
            <h1>test</h1>
        )
    }
}

export default Chirp;