{"id":22328728,"url":"https://github.com/seangenabe/uget","last_synced_at":"2026-05-04T06:33:13.965Z","repository":{"id":57385060,"uuid":"70878777","full_name":"seangenabe/uget","owner":"seangenabe","description":"Isomorphic JSON API helper on top of the Fetch API.","archived":false,"fork":false,"pushed_at":"2018-07-22T21:42:18.000Z","size":15,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-31T08:16:11.088Z","etag":null,"topics":["fetch-api","json"],"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/seangenabe.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-14T06:01:12.000Z","updated_at":"2017-03-12T22:46:42.000Z","dependencies_parsed_at":"2022-09-07T14:51:54.445Z","dependency_job_id":null,"html_url":"https://github.com/seangenabe/uget","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seangenabe%2Fuget","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seangenabe%2Fuget/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seangenabe%2Fuget/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seangenabe%2Fuget/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/seangenabe","download_url":"https://codeload.github.com/seangenabe/uget/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245600735,"owners_count":20642350,"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","json"],"created_at":"2024-12-04T03:13:20.504Z","updated_at":"2026-05-04T06:33:13.904Z","avatar_url":"https://github.com/seangenabe.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# uget\n\nIsomorphic JSON API helper on top of the Fetch API.\n\n## Usage\n\n```javascript\nconst uget = require('uget')\n```\n\nOn the browser, the native Fetch API is used. On node, [node-fetch](https://npmjs.com/package/node-fetch) is used. (via [browserify](https://npmjs.com/package/browserify))\n\n### uget(input, init)\n\nFetches a resource from a URI.\n\n**Parameters** are the same as the native `GlobalFetch.fetch` function, but some defaults useful for JSON API endpoints are set for `init`:\n\n* `method` = `GET`\n* `headers` = `{ accept: 'application/json' }`\n\n  Can be used to distinguish between a JSON API request and a normal (HTML) request.\n\n* `credentials` = `same-origin`\n\n  Ensures that cookies are sent with the request.\n\n* `redirect` = `follow`\n\n  Follow redirects.\n\nIf you pass a plain object or an array to `init.body`, that will be serialized with `JSON.stringify()` and `{ 'content-type': 'application/json' }` will be added to the default `headers`.\n\n**Returns:**\n\nA `Promise` that resolves with a value or rejects with an `Error`:\n\n* If the response is not OK (does not have status 2xx):\n  1. Parses the response body.\n    * If the response body is valid JSON, attempts to get the `message` property and incorporates it into the error message.\n    * If the response body is valid plaintext, gets the first hundred characters and incorporates it into the error message.\n  2. Throws an error.\n* If the response status is 204:\n  * Returns `undefined`.\n* Parses the response body as text\n  * If the response body is empty, returns `undefined`.\n  * Parses the response body text as JSON and returns it.\n\nIf the response is not OK and has a plaintext body, the error object will additionally have the `payload` property containing the response body. Furthermore, if it's valid JSON, the `payloadJson` property will be set containing the JSON object. Thirdly, if a `message` property was found, the `payloadJsonDetail` property will be set containing its value.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseangenabe%2Fuget","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseangenabe%2Fuget","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseangenabe%2Fuget/lists"}