diff --git a/src/App.js b/src/App.js index dfb78fc..8acf65a 100644 --- a/src/App.js +++ b/src/App.js @@ -3,16 +3,33 @@ import logo from './logo.svg' import './App.css' class App extends Component { + state = { + todos: [] + } componentDidMount() { console.log('fetch items') - fetch('https://adoring-clarke-f30908.netlify.com/.netlify/functions/todos-read-all') + fetch('/.netlify/functions/todos-read-all') .then((response) => { + console.log(response) return response.json() }) .then((myJson) => { console.log(myJson) + this.setState({ + todos: myJson.data + }) }) } + renderTodos() { + const { todos } = this.state + return todos.map((todo, i) => { + return ( +
+ {todo['@ref']} +
+ ) + }) + } render() { return (
@@ -23,6 +40,7 @@ class App extends Component {

Using FaunaDB & netlify functions

+ {this.renderTodos()}
) }