Skip to content

Commit

Permalink
Create DataSubmit.js
Browse files Browse the repository at this point in the history
  • Loading branch information
flemmerz authored Dec 9, 2024
1 parent a4ac1f1 commit 97c032b
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/components/DataSubmit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React, { useState } from "react";

function DataSubmit() {
const [dataHash, setDataHash] = useState("");

const handleSubmit = () => {
fetch("/api/data/submit", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ contributor: "user_address", dataHash }),
})
.then((res) => res.json())
.then((data) => console.log(data));
};

return (
<div>
<h2>Submit Data</h2>
<input
type="text"
value={dataHash}
onChange={(e) => setDataHash(e.target.value)}
placeholder="Enter data hash"
/>
<button onClick={handleSubmit}>Submit</button>
</div>
);
}

export default DataSubmit;

0 comments on commit 97c032b

Please sign in to comment.