{"id":15601160,"url":"https://github.com/hacknlove/fetchhelper","last_synced_at":"2025-04-26T21:32:17.218Z","repository":{"id":35043633,"uuid":"200032333","full_name":"hacknlove/fetchHelper","owner":"hacknlove","description":null,"archived":false,"fork":false,"pushed_at":"2023-01-04T07:29:25.000Z","size":429,"stargazers_count":3,"open_issues_count":9,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-21T22:23:18.615Z","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":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hacknlove.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2019-08-01T10:47:00.000Z","updated_at":"2024-04-25T02:50:19.000Z","dependencies_parsed_at":"2023-01-15T12:38:38.089Z","dependency_job_id":null,"html_url":"https://github.com/hacknlove/fetchHelper","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/hacknlove%2FfetchHelper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacknlove%2FfetchHelper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacknlove%2FfetchHelper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacknlove%2FfetchHelper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hacknlove","download_url":"https://codeload.github.com/hacknlove/fetchHelper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251057627,"owners_count":21529641,"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-03T02:18:56.502Z","updated_at":"2025-04-26T21:32:16.940Z","avatar_url":"https://github.com/hacknlove.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fetchHelper\n![coverage 100%](https://img.shields.io/badge/coverage-100%25-brightgreen)\n\n```\nnpm i @hacknlove/fetchhelper\n```\n\nPolymorphic fetch helper that allows you to pass the parameters in many ways, and brings you the response conveniently processed for your REST APIs, with no dependences and less than 600 bytes.\n\n## Parameters\n\n### As usual `fetchHelper(url, options)`\nSame as calling `fetch(url, options)`\n\n### As an array `fetchHelper([url, options])`\nSame as calling `fetch(url, options)`\n\n### Promise that will resolve in url `fetchHelper(promise, options)`\nSame as calling `fetch(await promise, options)`\n\n### Promise that will resolve in [url, options] `fetchHelper(promise)`\nSame as calling `fetch(await promise)`\n\n### Callfront that will return url `fetchHelper(callfront, options)`\nSame as calling `fetch(callfront(), options)`\n\n### Callfront that will return [url, options] `fetchHelper(callfront)`\nSame as calling `fetch(callfront())`\n\n### Callfront that will return a promise that will resolve to url `fetchHelper(callfront, options)`\nSame as calling `fetch(await callfront(), options)`\n\n### Callfront that will return a promise that will resolve to [url, options] `fetchHelper(callfront)`\nSame as calling `fetch(await callfront())`\n\n### options.json\nIt sets the body to JSON.stringify(options.json), and the Content-Type to application/json\n\n## Return\n\nIt returns a promise that will resolve to `[response, error]`, and never rejects\n\n### If fetch rejects to `error`\n`[null, error]`\n\nWhen\n\n### If fetch resolves to `{ok: false, .....}`\n`[null, {ok: false, .....}]`\n\n### If fetch resolves to `{ok: true, ....}`\n`[await response.json(), udefined]`\n\n### If json has error\n`[null, json]`\n\n## Isomorphic\n\nYou can install the polyfill you want, or you can assign the `fetch` you like to `fetchHelper.fetch`\n\n```\nimport myFetchLibrary from 'myfetchlibrary'\nimport fetchHelper from '@hacknlove/fetchhelper'\n\nfetchHelper.fetch\n```\n\n## test this module\n\n```\ngit clone https://github.com/hacknlove/fetchHelper.git\ncd fetchHelper\nnpm install\nnpm test\n```\n\n## mock\nI recomend to mock `fetch` instead\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhacknlove%2Ffetchhelper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhacknlove%2Ffetchhelper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhacknlove%2Ffetchhelper/lists"}