{"id":16372893,"url":"https://github.com/mucsi96/react-use-api","last_synced_at":"2025-08-05T02:19:15.699Z","repository":{"id":51461375,"uuid":"272276131","full_name":"mucsi96/react-use-api","owner":"mucsi96","description":"React hook for fetching data.","archived":false,"fork":false,"pushed_at":"2021-05-11T19:52:04.000Z","size":1451,"stargazers_count":0,"open_issues_count":5,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-01T09:30:27.394Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/mucsi96.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}},"created_at":"2020-06-14T20:14:05.000Z","updated_at":"2020-06-22T05:37:21.000Z","dependencies_parsed_at":"2022-09-12T22:12:45.366Z","dependency_job_id":null,"html_url":"https://github.com/mucsi96/react-use-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mucsi96/react-use-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mucsi96%2Freact-use-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mucsi96%2Freact-use-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mucsi96%2Freact-use-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mucsi96%2Freact-use-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mucsi96","download_url":"https://codeload.github.com/mucsi96/react-use-api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mucsi96%2Freact-use-api/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268820723,"owners_count":24312461,"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","status":"online","status_checked_at":"2025-08-05T02:00:12.334Z","response_time":2576,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-10-11T03:12:41.564Z","updated_at":"2025-08-05T02:19:15.661Z","avatar_url":"https://github.com/mucsi96.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-use-api\n\nReact hook for fetching data.\n\n## Usage with ErrorBoundary\n```typescript\nimport { useApi } from \"./useApi\";\n\nfunction useSearchByName(name: string) {\n  return useApi\u003cstring[]\u003e({\n    method: \"GET\",\n    url: `/api/search/${name}`\n  });\n}\n\nconst [names, search, loading] = useSearchByName(searchString);\n```\n\n## Usage without ErrorBoundary\n```typescript\nimport { useApi } from \"./useApi\";\n\nfunction useSearchByName(name: string) {\n  return useApi\u003cstring[]\u003e({\n    method: \"GET\",\n    url: `/api/search/${name}`,\n    noErrorPropagationBoundary: true\n  });\n}\n\nconst [names, search, loading, error] = useSearchByName(searchString);\n```\n\n## Usage of ApiContextProvider\n\n```typescript\nexport default function App() {\n  const apiContext = useMemo\u003cApiContext\u003e(\n    () =\u003e ({\n      enhanceRequest(request) {\n        request.headers.append(\n          \"x-this-header\",\n          \"was-added-on-application-level\"\n        );\n        return Promise.resolve(request);\n      },\n      postFetch(response, error) {\n        console.log(\"this log was made on application level\", {\n          response,\n          error,\n        });\n        return Promise.resolve();\n      },\n    }),\n    []\n  );\n  return (\n    \u003cApiContextProvider {...apiContext}\u003e\n      \u003cErrorBoundary\u003e\n        \u003cSearchForm /\u003e\n      \u003c/ErrorBoundary\u003e\n    \u003c/ApiContextProvider\u003e\n  );\n}\n```\n\n## Features\n- Fetching data using fetchAPI\n- Returning data, load function, loading state, error state\n- Error handling for server and network errors\n- Support for error boundaries\n- Request cancelling on component unmount\n- Request cancelling on prop change\n- Request enhacing on application / context level. For example adding some headers\n- Response processing on application / context level. For example logging errors.\n\n## Fetching data using fetchAPI\n\n![Animated GIF-downsized](https://user-images.githubusercontent.com/3163392/85226978-99a21480-b3da-11ea-8262-cc7163124b3b.gif)\n\n## Error handling for server errors\n\n![Animated GIF-downsized (1)](https://user-images.githubusercontent.com/3163392/85226980-9c9d0500-b3da-11ea-8998-c565d1dbc1ae.gif)\n\n## Error handling for network errors\n\n![Animated GIF-downsized (6)](https://user-images.githubusercontent.com/3163392/85227148-d0c4f580-b3db-11ea-827c-7ab23b8672a9.gif)\n\n## Support for error boundaries\n\n![Animated GIF-downsized (3)](https://user-images.githubusercontent.com/3163392/85226984-a161b900-b3da-11ea-8303-b38faabeb8f3.gif)\n\n## Request cancelling on component unmount\n\n![Animated GIF-downsized (4)](https://user-images.githubusercontent.com/3163392/85226987-a3c41300-b3da-11ea-956f-7836d5552611.gif)\n\n## Request cancelling on prop change\n\n![Animated GIF-downsized (7)](https://user-images.githubusercontent.com/3163392/85227149-d28eb900-b3db-11ea-8e50-28b6fac65ff7.gif)\n\n## Request enhacing on application / context level\n\n![Animated GIF-downsized (8)](https://user-images.githubusercontent.com/3163392/85233355-d6cfcc00-b405-11ea-97e1-da4af116512a.gif)\n\n## Response processing on application / context level\n\n![Animated GIF-downsized (9)](https://user-images.githubusercontent.com/3163392/85233410-329a5500-b406-11ea-9dde-82ddb568c3f1.gif)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmucsi96%2Freact-use-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmucsi96%2Freact-use-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmucsi96%2Freact-use-api/lists"}