Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { useState } from "react";
- const useFetch = async (url)=>{
- const [data, setData] = useState(null);
- const response = await fetch(url,{
- method: "GET",
- headers: {
- "Content-Type":"application/json",
- }
- })
- setData(await response.json());
- console.log({data});
- if(response.status === 200){
- return data
- }
- }
- export default useFetch;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement