forked from LukeMwila/multi-container-nginx-react-node-mongo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
37 lines (32 loc) · 772 Bytes
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import React from 'react';
import './App.css';
function App() {
const [toDoItems, updateToDoItems] = React.useState([]);
React.useEffect(() => {
const getToDoItems = async () => {
const response = await fetch(
`/backend/v1/to-do`
);
const items = await response.json();
if (items && Array.isArray(items) && items.length) {
updateToDoItems(items);
}
};
getToDoItems();
}, []);
return (
<div>
{toDoItems && toDoItems.length
? toDoItems.map((item, i) => {
return (
<div key={i}>
{`${item.item_name}`}
<br />
</div>
);
})
: 'No items to be done'}
</div>
);
}
export default App;