{"id":17353256,"url":"https://github.com/zacanger/fetchyeah","last_synced_at":"2025-04-14T21:25:27.228Z","repository":{"id":55562335,"uuid":"184786012","full_name":"zacanger/fetchyeah","owner":"zacanger","description":"Miniscule JSON fetch wrapper library.","archived":false,"fork":false,"pushed_at":"2024-04-23T17:21:31.000Z","size":2578,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":16,"default_branch":"master","last_synced_at":"2024-04-23T19:23:03.703Z","etag":null,"topics":["browser","fetch","json","node","request","xhr"],"latest_commit_sha":null,"homepage":"http://npm.im/fetchyeah","language":"TypeScript","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/zacanger.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-05-03T16:17:09.000Z","updated_at":"2024-06-18T19:11:07.588Z","dependencies_parsed_at":"2023-09-24T10:32:44.156Z","dependency_job_id":"3b20c41f-b255-42cc-9be4-a936ef0e6f0a","html_url":"https://github.com/zacanger/fetchyeah","commit_stats":{"total_commits":146,"total_committers":2,"mean_commits":73.0,"dds":0.0273972602739726,"last_synced_commit":"e81016a5fca2a3d28339a38011114481d8dd789c"},"previous_names":[],"tags_count":65,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zacanger%2Ffetchyeah","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zacanger%2Ffetchyeah/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zacanger%2Ffetchyeah/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zacanger%2Ffetchyeah/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zacanger","download_url":"https://codeload.github.com/zacanger/fetchyeah/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248961747,"owners_count":21190077,"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":["browser","fetch","json","node","request","xhr"],"created_at":"2024-10-15T17:16:07.652Z","updated_at":"2025-04-14T21:25:27.204Z","avatar_url":"https://github.com/zacanger.png","language":"TypeScript","funding_links":["https://ko-fi.com/zacanger"],"categories":[],"sub_categories":[],"readme":"# fetchyeah\n\nTiny JSON fetch wrapper library. ~1.7kb gzipped.\n\n[![npm version](https://img.shields.io/npm/v/fetchyeah.svg)](https://npm.im/fetchyeah) [![ko-fi](https://img.shields.io/badge/donate-KoFi-yellow.svg)](https://ko-fi.com/zacanger)\n\n----\n\n`fetchyeah` is a small fetch wrapper library that always parses JSON and returns\nJS. Smaller than Axios, Request, R2, and the `whatwg-fetch` polyfill itself.\n\n# Installation\n\n`npm i fetchyeah`\n\n# Usage\n\n```javascript\nimport { get } from 'fetchyeah'\n\nget('/foo')\n```\n\n## Methods\n\n* `del`\n* `get`\n* `patch`\n* `post`\n* `put`\n\nThis only provides functions for these common HTTP methods, but you can easily add\nyour own. Check out the source for notes on how to use `sendJson` directly.\n\nThe return value is always a simple response of type\n\n```typescript\ntype SimpleResponse\u003cT\u003e = {\n  ok: boolean\n  status: number\n  headers: Headers\n  body: T\n}\n```\n\n## Examples\n\nNode:\n\n```javascript\nrequire('isomorphic-fetch') // brings in fetch for Node\n\nimport * as f from 'fetchyeah'\n\n// some koa route\nrouter.get('/foo/:id', async (ctx) =\u003e {\n  try {\n    const thing = await f.get(`/some-service/${id}`)\n    ctx.type = 'application/json'\n    ctx.body = thing\n  } catch (e) {\n    someLogger.error(e)\n    ctx.status = 500\n    ctx.body = e\n  }\n})\n```\n\nBrowser:\n\n```javascript\nimport * as React from 'react'\nimport { post } from 'fetchyeah'\n\nclass Foo extends React.Component {\n  state = { things: null }\n\n  submitThings = () =\u003e {\n    post('/stuff', { body: this.state.things })\n    .then((res) =\u003e {\n      if (res) {\n        alert(res)\n      }\n    })\n    .catch((err) =\u003e {\n      someErrorHandler(err)\n    })\n  }\n\n  setThings = (e) =\u003e {\n    this.setState({ things: e.target.value })\n  }\n\n  render () {\n    return (\n      \u003cReact.Fragment\u003e\n        \u003cinput\n          type=\"text\"\n          onChange={this.setThings}\n          value={this.state.things}\n        /\u003e\n        \u003cbutton onClick={submitThings}\u003e\n          Send the things!\n        \u003c/button\u003e\n      \u003c/React.Fragment\u003e\n    )\n  }\n}\n```\n\nAdding headers:\n\n```javascript\nimport { post } from 'fetchyeah'\n\npost('/foo', {\n  body: someObject,\n  headers: {\n    'x-foo-bar': 'baz',\n  }\n})\n```\n\n## Environment\n\nThis library assumes `fetch` is available. You may need to polyfill it!\n\n[LICENSE](./LICENSE.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzacanger%2Ffetchyeah","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzacanger%2Ffetchyeah","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzacanger%2Ffetchyeah/lists"}