set iniitial state to book data fetched by getAll
This commit is contained in:
11
src/App.js
11
src/App.js
@@ -8,10 +8,15 @@ import './App.css'
|
||||
|
||||
class BooksApp extends React.Component {
|
||||
|
||||
state = {
|
||||
books: []
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
getAll().then((books) =>
|
||||
console.log(books)
|
||||
)
|
||||
getAll().then((books) => {
|
||||
console.log(books)
|
||||
this.setState({ books })
|
||||
})
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
Reference in New Issue
Block a user