{"id":13847062,"url":"https://github.com/the-road-to-learn-react/use-data-api","last_synced_at":"2025-04-10T04:56:20.805Z","repository":{"id":47229435,"uuid":"190453560","full_name":"the-road-to-learn-react/use-data-api","owner":"the-road-to-learn-react","description":"Custom hook for React Components to fetch data from an API.","archived":false,"fork":false,"pushed_at":"2020-06-12T08:29:44.000Z","size":122,"stargazers_count":242,"open_issues_count":1,"forks_count":20,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-02T16:57:22.300Z","etag":null,"topics":["react","react-data","react-fetch","reactjs"],"latest_commit_sha":null,"homepage":"https://www.robinwieruch.de/react-hooks-fetch-data","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/the-road-to-learn-react.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"rwieruch","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2019-06-05T19:09:08.000Z","updated_at":"2024-11-27T08:24:15.000Z","dependencies_parsed_at":"2022-09-06T19:42:08.040Z","dependency_job_id":null,"html_url":"https://github.com/the-road-to-learn-react/use-data-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/the-road-to-learn-react%2Fuse-data-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/the-road-to-learn-react%2Fuse-data-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/the-road-to-learn-react%2Fuse-data-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/the-road-to-learn-react%2Fuse-data-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/the-road-to-learn-react","download_url":"https://codeload.github.com/the-road-to-learn-react/use-data-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248161261,"owners_count":21057554,"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":["react","react-data","react-fetch","reactjs"],"created_at":"2024-08-04T18:00:53.447Z","updated_at":"2025-04-10T04:56:20.779Z","avatar_url":"https://github.com/the-road-to-learn-react.png","language":"JavaScript","readme":"# useDataApi React Hook\n\n[![Build Status](https://travis-ci.org/the-road-to-learn-react/use-data-api.svg?branch=master)](https://travis-ci.org/the-road-to-learn-react/use-data-api) [![Slack](https://slack-the-road-to-learn-react.wieruch.com/badge.svg)](https://slack-the-road-to-learn-react.wieruch.com/) [![Greenkeeper badge](https://badges.greenkeeper.io/the-road-to-learn-react/use-data-api.svg)](https://greenkeeper.io/) ![NPM](https://img.shields.io/npm/l/use-data-api.svg)\n\nCustom hook for React Components to fetch data from an API. [Read more about it.](https://www.robinwieruch.de/react-hooks-fetch-data/).\n\n[Example over here.](https://github.com/the-road-to-learn-react/react-hooks-introduction/blob/master/src/useDataApiHook-external-example/index.js)\n\n## Installation\n\n`npm install use-data-api`\n\n## Usage\n\nAccepts as first argument an endpoint URL and as second argument an initial state for `data`. It returns as first item in an array an object which holds the data, isLoading and isError states, and the actual function to fetch the data (e.g. on a button click).\n\n```\nimport React from 'react';\n\nimport useDataApi from 'use-data-api';\n\nconst AnyComponent = props =\u003e {\n  const [{ data, isLoading, isError }, doFetch] = useDataApi(\n    'http://hn.algolia.com/api/v1/search?query=redux',\n    null,\n  );\n\n  ...\n};\n```\n\n## Contribute\n\n* `git clone git@github.com:the-road-to-learn-react/use-data-api.git`\n* `cd use-data-api`\n* `npm install`\n* `npm run test`\n\n### More\n\n* [Publishing a Node Package to NPM](https://www.robinwieruch.de/publish-npm-package-node/)\n* [Node.js Testing Setup](https://www.robinwieruch.de/node-js-testing-mocha-chai/)\n* [React Testing Setup](https://www.robinwieruch.de/react-testing-tutorial/)\n","funding_links":["https://github.com/sponsors/rwieruch"],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthe-road-to-learn-react%2Fuse-data-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthe-road-to-learn-react%2Fuse-data-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthe-road-to-learn-react%2Fuse-data-api/lists"}