Created
July 15, 2022 13:21
-
-
Save hesan-aminiloo/cf4988045c4d53c4ab96049e332cba79 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const useFetch = (path, method) => { | |
const [data, setData] = useState(null); | |
useEffect(() => { | |
fetch(path, { method: method.toUpperCase() }) | |
.then((response) => response.json()) | |
.then((json) => setData(json)); | |
}, []); | |
return data; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment