Add: simple update database function
This commit is contained in:
@@ -1,9 +1,51 @@
|
|||||||
|
import { useState } from "react";
|
||||||
|
|
||||||
function Manage() {
|
function Manage() {
|
||||||
return (
|
const [token, setToken] = useState("");
|
||||||
<div>
|
const [walkPath, setWalkPath] = useState("");
|
||||||
<h2>Manage</h2>
|
|
||||||
</div>
|
function updateDatabase() {
|
||||||
)
|
fetch("/api/v1/walk", {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
token: token,
|
||||||
|
root: walkPath,
|
||||||
|
pattern: [".wav", ".mp3"],
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
.then((res) => res.json())
|
||||||
|
.then((data) => {
|
||||||
|
console.log(data);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h2>Manage</h2>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
value={token}
|
||||||
|
placeholder="token"
|
||||||
|
onChange={(e) => setToken(e.target.value)}
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
value={walkPath}
|
||||||
|
placeholder="walk path"
|
||||||
|
onChange={(e) => setWalkPath(e.target.value)}
|
||||||
|
/>
|
||||||
|
<button
|
||||||
|
onClick={() => {
|
||||||
|
updateDatabase();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Update Database
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Manage;
|
export default Manage;
|
||||||
|
|||||||
Reference in New Issue
Block a user