const [stuff, setStuff] = useState([]);
const request = "example/tasks.json", {
method: "POST",
body: JSON.stringify(taskData),
headers: { "Content-Type": "application/json" },
};
useEffect( ()=> {
fetch(request)
.then(response => response.json())
.then(data => setStuff(data.hits))
.catch(err => {console.log(err)})
},[])
Last active
November 10, 2021 13:51
-
-
Save dnh33/f2ff9df85dcf2d70916691dcdb973b1f to your computer and use it in GitHub Desktop.
React Fetch Request with State
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment