{"id":16009736,"url":"https://github.com/hirohe/fetch-request","last_synced_at":"2025-04-05T02:24:42.775Z","repository":{"id":57116035,"uuid":"142810166","full_name":"hirohe/fetch-request","owner":"hirohe","description":"wrapper of isomorphic-fetch //WIP","archived":false,"fork":false,"pushed_at":"2018-07-31T04:18:58.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-02T01:02:58.641Z","etag":null,"topics":["fetch","request"],"latest_commit_sha":null,"homepage":null,"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/hirohe.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":"2018-07-30T01:34:26.000Z","updated_at":"2018-07-31T04:18:59.000Z","dependencies_parsed_at":"2022-08-22T22:20:11.839Z","dependency_job_id":null,"html_url":"https://github.com/hirohe/fetch-request","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/hirohe%2Ffetch-request","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hirohe%2Ffetch-request/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hirohe%2Ffetch-request/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hirohe%2Ffetch-request/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hirohe","download_url":"https://codeload.github.com/hirohe/fetch-request/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247277556,"owners_count":20912545,"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":["fetch","request"],"created_at":"2024-10-08T13:03:58.131Z","updated_at":"2025-04-05T02:24:42.646Z","avatar_url":"https://github.com/hirohe.png","language":"JavaScript","readme":"fetch-request ![](https://img.shields.io/npm/v/@hirohe/fetch-request.svg)\n=============\n\na wrapper of [isomorphic-fetch](https://github.com/matthew-andrews/isomorphic-fetch)\n\nmake it more like 'axios'\n\n⚠️⚠️⚠️ still work in progress ⚠️⚠️⚠️\n\n### install\n\n```bash\nnpm install --save @hirohe/fetch-request\n```\n\n### usage\n\n#### example\n```js\nimport FetchRequest from '@hirohe/fetch-request'\n\nconst options = {\n  baseUrl: '/api',\n  headers: { 'content-type': 'application/json' },\n};\n// make new instance with options\nconst request = new FetchRequest(options);\n\n// setup response interceptor\nrequest.setupResponseInterceptor(response =\u003e {\n  // do something\n}, error =\u003e {\n  // handle with error\n});\n\n// GET /api/test?q=hello\u0026_t=1532915637137\n// will add timestamp param '_t' by default\nrequest.get('/test', { params: { q: 'hello' } });\n```\n\n### request options\n\nrequest options use to initialze FetchRequest, extend from [RequestInit](https://fetch.spec.whatwg.org/#request-class)\n\n`const request = new FetchRequest(options);`\n\n```js\nexport interface RequestOptions extends RequestInit {\n  baseUrl?: string;\n  data?: object;\n  params?: object;\n  responseType?: 'json' | 'blob' | 'formData' | 'arrayBuffer' | 'text' | string;\n  withTimestamp?: boolean;\n}\n```\n\n- `baseUrl`: prepended to `url`.\n- `data`: the request body data, it should be plain object for now...\n- `params`: will add to request query string, should be plain object.\n- `responseType`: decide witch type of response is, can be 'json', 'blob', 'formData', 'arrayBuffer', 'text'. is 'json' by default\n- `withTimestamp`: weather append timestamp param to query string, e.g: `_t=1532915637137`. it makes each request unique, prevent getting cache from server, is `true` by default\n\n### request methods\n\nrequest.get(url\\[, options\\])\n\nrequest.delete(url\\[, options\\])\n\nrequest.head(url\\[, options\\])\n\nrequest.options(url\\[, options\\])\n\nrequest.post(url\\[, data\\[, options\\]\\])\n\nrequest.put(url\\[, data\\[, options\\]\\])\n\nrequest.patch(url\\[, data\\[, options\\]\\])\n\n\n... //WIP\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhirohe%2Ffetch-request","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhirohe%2Ffetch-request","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhirohe%2Ffetch-request/lists"}