added creating rooms in db

This commit is contained in:
Wenszel
2021-03-13 17:53:11 +01:00
parent 99d347a514
commit 12372ef4f2
9 changed files with 81 additions and 17 deletions
+1 -2
View File
@@ -1,10 +1,9 @@
import './App.css';
import NameInput from './components/NameInput';
function App() {
return (
<div>
<NameInput></NameInput>
<NameInput />
</div>
);
}
+5 -14
View File
@@ -1,23 +1,14 @@
import React, { useState } from 'react';
const NameInput = ()=>{
import axios from 'axios';
const NameInput = () => {
const [inputValue, setInputValue] = useState('');
const handleInputChange = (e) => {
setInputValue(e.target.value);
}
const handleButtonClick = () => {
const request = {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ name: inputValue })
};
fetch('localhost:3000/room/add', request)
.then(response => {
if(response.status == 200){
//redirect
}else{
//error
}
});
axios.post('http://localhost:3000/room/add')
}
return(
<div>