{"id":17497449,"url":"https://github.com/moox/simple-json-fetch","last_synced_at":"2025-12-23T19:30:50.492Z","repository":{"id":57360310,"uuid":"53168145","full_name":"MoOx/simple-json-fetch","owner":"MoOx","description":"whatwg fetch(), wrapped and enhanced for JSON response","archived":false,"fork":false,"pushed_at":"2019-11-06T17:52:26.000Z","size":5,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-05T21:42:13.081Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/MoOx.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}},"created_at":"2016-03-04T21:58:24.000Z","updated_at":"2017-10-20T05:04:44.000Z","dependencies_parsed_at":"2022-09-06T22:22:36.060Z","dependency_job_id":null,"html_url":"https://github.com/MoOx/simple-json-fetch","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MoOx%2Fsimple-json-fetch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MoOx%2Fsimple-json-fetch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MoOx%2Fsimple-json-fetch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MoOx%2Fsimple-json-fetch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MoOx","download_url":"https://codeload.github.com/MoOx/simple-json-fetch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239707801,"owners_count":19684135,"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":[],"created_at":"2024-10-19T15:47:51.456Z","updated_at":"2025-12-23T19:30:45.236Z","avatar_url":"https://github.com/MoOx.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# simple-json-fetch\n\n\u003e whatwg fetch(), wrapped and enhanced for JSON response.\n\n## Install\n\n**This module has no dependencies, so be sure to get your own fetch() polyfill if needed**\n(eg: [whatwg-fetch](https://www.npmjs.com/package/whatwg-fetch)).\n\n```console\n$ npm i -S simple-json-fetch [whatwg-fetch]\n```\n\n## Usage\n\nUse this module exactly like [fetch()](https://www.npmjs.com/package/whatwg-fetch),\nwith this in mind:\n\n- promise will be resolved only if http code is between 200~300 AND response\n  is valid json\n- otherwise promise is rejected\n  - http code \u003e= 300\n  - json is invalid\n\n```js\nimport \"whatwg-fetch\"\nimport jsonFetch from \"simple-json-fetch\"\n\njsonFetch(url, { /* ... */})\n.then(\n  // in both \"resolve\" or \"reject\" callback, you will get the original\n  // response (with fields like .status, .statusText...)\n\n  // json is correct and http code is in the 2xx range\n  // resolved response got a json property which is the js object\n  (response) =\u003e {\n    response.json\n    // json property is an object here, not a method that return\n    // a promise that resolve with an object (that the point of this module)\n  },\n  // json is malformed or http code is NOT in the 2xx range\n  // rejected response got an error property, which is the error thrown if any\n  (response) =\u003e {\n    response.error\n    // the error thrown (eg: during parsing of the json)\n  }\n)\n```\n\n## Warning\n\nNo automated tests because I am pushing this snippet I am using for one or two\nyears at midnight.\nFeel free to add some :)\n\n---\n\n## CONTRIBUTING\n\n* ⇄ Pull requests and ★ Stars are always welcome.\n* For bugs and feature requests, please create an issue.\n* Pull requests must be accompanied by passing automated tests (`$ npm test`).\n\n## [CHANGELOG](CHANGELOG.md)\n\n## [LICENSE](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoox%2Fsimple-json-fetch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoox%2Fsimple-json-fetch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoox%2Fsimple-json-fetch/lists"}