Clean up App component

This commit is contained in:
Justin Edmund 2020-09-15 01:25:20 -07:00
parent ae53dfdd9d
commit fbf3ab0213
2 changed files with 3 additions and 48 deletions

View file

@ -10,5 +10,7 @@ a {
h1 {
color: #444;
font-size: 18px;
font-weight: 500;
text-align: center;
}

View file

@ -5,54 +5,7 @@ import Header from './components/Header/Header'
import Main from './Main/Main'
function App() {
const [parties, setParties] = useState(false)
useEffect(() => {
getParty()
}, [])
function getParty() {
fetch('http://localhost:3001/parties')
.then(response => {
return response.text()
})
.then(data => {
setParties((data != null) ? true : false)
})
}
function createParty() {
fetch('http://localhost:3001/parties', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
}
// body: JSON.stringify({stuff})
})
.then(response => {
return response.text()
})
.then(data => {
alert(data)
getParty()
})
}
function deleteParty() {
let hash = prompt('Enter hash')
fetch(`http://localhost:3001/parties/${hash}`, {
method: 'DELETE'
})
.then(response => {
return response.text()
})
.then(data => {
alert(data)
getParty()
})
}
return (
return (
<div>
<Header />
<Main />