{"id":18913238,"url":"https://github.com/react-everywhere/re-quests","last_synced_at":"2025-04-15T08:30:46.310Z","repository":{"id":57343530,"uuid":"83708301","full_name":"react-everywhere/re-quests","owner":"react-everywhere","description":"Declarative networking for React.","archived":false,"fork":false,"pushed_at":"2017-09-09T09:03:56.000Z","size":99,"stargazers_count":19,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T15:51:44.687Z","etag":null,"topics":["ajax","axios","networking","react","react-native"],"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/react-everywhere.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":"2017-03-02T17:56:08.000Z","updated_at":"2023-11-07T12:44:48.000Z","dependencies_parsed_at":"2022-09-12T07:00:18.891Z","dependency_job_id":null,"html_url":"https://github.com/react-everywhere/re-quests","commit_stats":null,"previous_names":["ankitpopli1891/react-requests","ankitpopli1891/re-quests"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/react-everywhere%2Fre-quests","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/react-everywhere%2Fre-quests/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/react-everywhere%2Fre-quests/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/react-everywhere%2Fre-quests/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/react-everywhere","download_url":"https://codeload.github.com/react-everywhere/re-quests/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249035255,"owners_count":21202047,"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":["ajax","axios","networking","react","react-native"],"created_at":"2024-11-08T10:06:19.102Z","updated_at":"2025-04-15T08:30:45.998Z","avatar_url":"https://github.com/react-everywhere.png","language":"JavaScript","readme":"# re-quests\n\nDeclarative Networking for React.\n\n\n[![npm](https://img.shields.io/npm/v/re-quests.svg)](https://www.npmjs.com/package/re-quests)\n[![npm](https://img.shields.io/npm/dt/re-quests.svg)](https://www.npmjs.com/package/re-quests)\n\n\n## Quick Start\n\n__1. Install with NPM (or Yarn)__\n\n```\nnpm install --save re-quests\n```\n\n__2. Fire up a network request by rendering the `Request`.__\n\n```jsx\nimport Request from 're-quests';\n\n...\nrender (\n    \u003cRequest\n        url='https://my-awesome-doma.in/me'\n        onSuccess={this.myAwesomeResponseHandler}\u003e\n    \n        \u003cdiv\u003e {/* use View for react-native */}\n            \u003cRequest.Start\u003e\n                \u003cMyAwesomeSpinner /\u003e\n            \u003c/Request.Start\u003e\n            \u003cRequest.Success\u003e\n                \u003cMyAwesomeContent content={this.state.content} /\u003e\n            \u003c/Request.Success\u003e\n            \u003cRequest.Failure\u003e\n                \u003cMyAwesomeErrorMessage /\u003e\n            \u003c/Request.Failure\u003e\n        \u003c/div\u003e\n    \u003c/Request\u003e\n)\n```\n\n__3. Handle the response the way you want.__\n\n```js\nmyAwesomeResponseHandler = (response) =\u003e {\n    // set a local state\n    this.setState({\n        content: response.data\n    });\n    \n    // or dispatch an event\n    // this.props.dispatch(myAwesomeAction(response.data));\n}\n```\n\n## Recipes\n\nFor common day problems \u0026 how to's, check out the [Recipes] page.\n\n## Disclosure\n\nThe library being used for sending requests is [axios]. \n`Request` component is just a declarative wrapper around it, \nexposing a few of the capabilities of [axios]. \n\n\n\n## Props\n\n```js\n// `url` is the server URL that will be used for the request\nurl: PropTypes.string.isRequired,\n\n// the http method is not required by axios \u0026\n// defaults to 'get' if not provided\nmethod: PropTypes.oneOf(['get', 'post', 'put', 'patch', 'delete', 'head']),\n\n// `headers` are custom headers to be sent\nheaders: PropTypes.object,\n\n// `params` are the URL parameters to be sent with the request\n// Must be a plain object or a URLSearchParams object\nparams: PropTypes.object,\n\n// `data` is the data to be sent as the request body\n// Only applicable for request methods 'PUT', 'POST', and 'PATCH'\n// When no `transformRequest` is set, must be of one of the following types:\n// - string, plain object, ArrayBuffer, ArrayBufferView, URLSearchParams\n// - Browser only: FormData, File, Blob\n// - Node only: Stream\ndata: PropTypes.oneOfType([\n    PropTypes.string,\n    PropTypes.object,\n    PropTypes.instanceOf(ArrayBuffer),\n    PropTypes.instanceOf(ArrayBufferView),\n    PropTypes.instanceOf(URLSearchParams)\n]),\n\n// `paramsSerializer` is an optional function in charge of serializing `params`\n// (e.g. https://www.npmjs.com/package/qs, http://api.jquery.com/jquery.param/)\n// default: function(params) { return Qs.stringify(params, {arrayFormat: 'brackets'}) }\nparamsSerializer: PropTypes.func,\n\n// `transformRequest` allows changes to the request data before it is sent to the server\n// This is only applicable for request methods 'PUT', 'POST', and 'PATCH'\n// The last function in the array must return a string, an ArrayBuffer, FormData, or a Stream\ntransformRequest: PropTypes.arrayOf(PropTypes.func),\n\n// `transformResponse` allows changes to the response data to be made before\n// it is passed to then/catch\ntransformResponse: PropTypes.arrayOf(PropTypes.func),\n\n// `validateStatus` defines whether to resolve or reject the promise for a given\n// HTTP response status code. If `validateStatus` returns `true` (or is set to `null`\n// or `undefined`), the promise will be resolved; otherwise, the promise will be\n// rejected.\n// default: function (status) { return status \u003e= 200 \u0026\u0026 status \u003c 300; }\nvalidateStatus: PropTypes.func,\n\n// `maxRedirects` defines the maximum number of redirects to follow in node.js.\n// If set to 0, no redirects will be followed.\n// default: 5\nmaxRedirects: PropTypes.number,\n\n// `timeout` specifies the number of milliseconds before the request times out.\n// If the request takes longer than `timeout`, the request will be aborted.\ntimeout: PropTypes.number,\n\n// `auth` indicates that HTTP Basic auth should be used, and supplies credentials.\n// This will set an `Authorization` header, overwriting any existing\n// `Authorization` custom headers you have set using `headers`.\n// { username: 'janedoe', password: 's00pers3cret' }\nauth: PropTypes.shape({\n    username: PropTypes.string,\n    password: PropTypes.string\n}),\n\n// `responseType` indicates the type of data that the server will respond with\n// options are 'arraybuffer', 'blob', 'document', 'json', 'text', 'stream'\n// default: json\nresponseType: PropTypes.oneOf(['arraybuffer', 'blob', 'document', 'json', 'text', 'stream']),\n\n// `xsrfCookieName` is the name of the cookie to use as a value for xsrf token\n// default: 'XSRF-TOKEN'\nxsrfCookieName: PropTypes.string,\n\n// `xsrfHeaderName` is the name of the http header that carries the xsrf token value\n// default: 'X-XSRF-TOKEN'\nxsrfHeaderName: PropTypes.string,\n\n\n// callback fired just before the request is fired\nonStart: PropTypes.func,\n\n// callback fired after the response \n// comes back with status 2XX\nonSuccess: PropTypes.func,\n\n// callback fired after the response \n// comes back with status other 2XX\nonFailure: PropTypes.func,\n\n// callback fired when \n// something else goes wrong\nonError: PropTypes.func,\n\n// defer signals the Request component to not fire the \n// request as soon as ready instead construct the request and \n// wait for the manual trigger\n// useful for cases when either the data is incomplete \n// or we want to wait for a CTA \ndefer: PropTypes.bool,\n\n// request can be tagged for enabling nested scenarios\n// we might want to render a component based on \n// request sent way above the hierarchy of the component\n// super grand parent component :P\ntag: PropTypes.string\n```\n\n## Limitations\n\n - All `re-quests` components can only have one direct child. \n Just like [render can only return one child][2127]. This will be fixed with react 16. \n\n## Contribution\n\nAny and all the contribution is welcome, providing it aligns with the interest of the project. \nPlease make sure the commit messages follow the convention from the [git commit template][template].\n\n\n[Recipes]: https://github.com/ankitpopli1891/re-quests/wiki/Recipes\n[template]: https://github.com/ankitpopli1891/re-quests/blob/master/.gitmessage\n[axios]: https://github.com/mzabriskie/axios\n[2127]: https://github.com/facebook/react/issues/2127\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freact-everywhere%2Fre-quests","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freact-everywhere%2Fre-quests","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freact-everywhere%2Fre-quests/lists"}