{"id":22419318,"url":"https://github.com/devsany/custom-hook","last_synced_at":"2025-07-14T16:06:17.159Z","repository":{"id":248857054,"uuid":"829983219","full_name":"devsany/custom-hook","owner":"devsany","description":"API Custom Hook","archived":false,"fork":false,"pushed_at":"2024-07-17T12:08:20.000Z","size":18,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-27T04:32:19.015Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devsany.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-17T11:30:38.000Z","updated_at":"2024-07-17T12:08:23.000Z","dependencies_parsed_at":"2024-07-17T14:36:22.589Z","dependency_job_id":null,"html_url":"https://github.com/devsany/custom-hook","commit_stats":null,"previous_names":["devsany/custom-hook"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/devsany/custom-hook","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devsany%2Fcustom-hook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devsany%2Fcustom-hook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devsany%2Fcustom-hook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devsany%2Fcustom-hook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devsany","download_url":"https://codeload.github.com/devsany/custom-hook/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devsany%2Fcustom-hook/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265314420,"owners_count":23745265,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-05T16:14:58.732Z","updated_at":"2025-07-14T16:06:17.131Z","avatar_url":"https://github.com/devsany.png","language":"JavaScript","readme":"# custom-hook\n\nWeb API Custom Hook\n\n# How to use this Repo\n\n1.  Clone this Repo to your application.\n2.  No need to download axios lib for fetching data.\n3.  Primary File:-Fetch.jsx\n    secondary File:-CheckFetchFunction.jsx\n    \n5.  # Primary File over View\n```javascript\n        import { useEffect, useState } from \"react\";\n        \n        const useFetch = (api) =\u003e { \n        const [data, setData] = useState(null); \n        const [error, setError] = useState(null); \n        const [loading, setLoading] = useState(true); \n        useEffect(() =\u003e {\u003c/br\u003e\n        const apiData = async () =\u003e { \n        try { \n        const data = await fetch(api); \n        const res = await data.json();\n        setData(res);\n        } catch (error) {\n        setError(\"api is not found plz put api in useFetch(\\_\\_\\_)\");\n        } finally {\n        setLoading(false);\n        }\n        };\n        apiData();\n        }, [api]);\n        return { data, error, loading };\n        };\n        export default useFetch;\n```\n6.  # Secondary File over View\n```javascript\n        import React, { useState } from \"react\";\n        import useFetch from \"./fetch\";\n\n        const CheckFetchFunction = () =\u003e {\n        const apiValue = \"https://jsonplaceholder.typicode.com/photos\";\n        const { data, error, loading } = useFetch(apiValue);\n        if (loading === true) {\n        console.log(\"...loading\");\n        } else {\n        console.log(data);\n        }\n        return (\n        \u003cdiv\u003e\n        {loading\n        ? \"...loading\"\n        : `${data.map((i) =\u003e {\n        return (\n        \u003c\u003e\n        \u003cdiv\u003e\n        \u003cspan\u003e{i.title}\u003c/span\u003e\n        \u003c/div\u003e\n        \u003c/\u003e\n        );\n        })}`}\n        \u003c/div\u003e\n        );\n        };\n\n        export default CheckFetchFunction;\n```\n7.  Copy All line from 5th point and peast in you application\n8.  Modify the changes in your project.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevsany%2Fcustom-hook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevsany%2Fcustom-hook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevsany%2Fcustom-hook/lists"}