{"id":15293364,"url":"https://github.com/panjiesw/frest","last_synced_at":"2025-04-13T13:17:05.193Z","repository":{"id":37933179,"uuid":"79120392","full_name":"panjiesw/frest","owner":"panjiesw","description":"Browser REST client wrapper of Fetch API with XHR fallback and interceptors","archived":false,"fork":false,"pushed_at":"2023-02-28T03:09:16.000Z","size":4452,"stargazers_count":11,"open_issues_count":4,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-13T13:16:47.883Z","etag":null,"topics":["fetch-api","rest-client","typescript","xhr"],"latest_commit_sha":null,"homepage":"https://panjiesw.github.io/frest","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/panjiesw.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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":"2017-01-16T13:22:00.000Z","updated_at":"2022-04-05T14:35:20.000Z","dependencies_parsed_at":"2024-06-21T05:10:34.527Z","dependency_job_id":"6d209056-7ef7-496d-95a6-b6150ee69e5a","html_url":"https://github.com/panjiesw/frest","commit_stats":{"total_commits":148,"total_committers":2,"mean_commits":74.0,"dds":0.006756756756756799,"last_synced_commit":"4c0a1a53435132cf74de6039ab7fe2fa1eb5fac1"},"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panjiesw%2Ffrest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panjiesw%2Ffrest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panjiesw%2Ffrest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panjiesw%2Ffrest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/panjiesw","download_url":"https://codeload.github.com/panjiesw/frest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248717237,"owners_count":21150389,"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-api","rest-client","typescript","xhr"],"created_at":"2024-09-30T16:47:10.006Z","updated_at":"2025-04-13T13:17:05.140Z","avatar_url":"https://github.com/panjiesw.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"https://frest.netlify.com/img/logo-256.png\" alt=\"logo\" height=\"120\" align=\"right\" /\u003e\n\n# Frest\n\n[![Build Status](https://img.shields.io/travis/panjiesw/frest/master.svg?style=flat-square)](https://travis-ci.org/panjiesw/frest) [![codecov](https://img.shields.io/codecov/c/github/panjiesw/frest/master.svg?style=flat-square)](https://codecov.io/gh/panjiesw/frest) [![npm](https://img.shields.io/npm/v/frest.svg?style=flat-square)](https://www.npmjs.com/package/frest) [![npm bundle size (minified + gzip)](https://img.shields.io/bundlephobia/minzip/frest.svg?style=flat-square)](https://bundlephobia.com/result?p=frest)\n\n\u003e Browser REST client wrapper of [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) with XHR fallback and interceptor support\n\n\u003c!-- [Go to full documentation](https://frest.netlify.com). --\u003e\n\n## Features\n\n- HTTP methods shortcut and CRUD aliases\n- XMLHttpRequest fallback, for file download/upload (with progress event) and when Fetch API is not available\n- Interceptors to manipulate request/response/error:\n  - Before request, add additional config for all/some operation before firing the request\n  - After response, transform response before returning for all/some operation\n  - Error, catch all error / request retry possibility\n- Include UMD build for direct usage in html script tag\n- Include TypeScript definition\n\n## Usage\n\nInstall the package using `npm` or `yarn`\n\n```bash\nnpm install --save frest\n# or\nyarn add frest\n```\n\nOr include the UMD build directly in a script tag\n\n```html\n\u003cscript type=\"text/javascript\" src=\"https://unpkg.com/frest\"\u003e\u003c/script\u003e\n```\n\nBasic examples.\n\n```typescript\nimport frest from 'frest';\n// in UMD build, frest, Frest and FrestError are included in Window object\n\n// with default instance\n// call HTTP method\nfrest\n  // request config will override the default config of Frest instance\n  .get('foo', { headers: new Headers({ 'X-Foo': 'foo' }) })\n  .then(res =\u003e {\n    // res is an object containing Fetch's response and the body\n    console.log('origin', res.origin);\n    // by default, without any interceptors, the body is undefined\n    console.log('body', res.body);\n    if (res.origin.ok) {\n      return res.origin.json();\n    }\n    Promise.reject('uh oh');\n  })\n  .then(body =\u003e {\n    console.log('body', body);\n  })\n  .catch(err =\u003e {\n    // err is an instance of FrestError\n    console.error('err', err);\n  });\n\n// available methods\napi.post(...) // HTTP POST\napi.put(...) // HTTP PUT\napi.delete(...) // HTTP DELETE\napi.patch(...) // HTTP PATCH\napi.option(...) // HTTP OPTION\napi.download(...) // Download file, support onDownloadProgress event\napi.upload(...) // Upload file, support onUploadProgress event\n\n// Use with async-await style\nasync function makeRequest() {\n  try {\n    const res = await api.post('blah');\n    if (res.ok) {\n      const body = await res.origin.json();\n      console.log('body', body);\n    }\n  } catch (err) {\n    console.error('request failed', err);\n  }\n}\n\n// With custom instance\nconst api = frest.create('https://api.example.com');\n\n// config extends Fetch's init option\nconst api = frest.create({\n  base: 'https://api.example.com',\n  headers: new Headers({\n    'X-Foo': 'bar',\n  }),\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpanjiesw%2Ffrest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpanjiesw%2Ffrest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpanjiesw%2Ffrest/lists"}