{"id":18554660,"url":"https://github.com/realmteam/easyfetch","last_synced_at":"2025-06-21T22:39:45.661Z","repository":{"id":57218862,"uuid":"87418402","full_name":"RealmTeam/easyfetch","owner":"RealmTeam","description":"Simple wrapper around fetch with json support","archived":false,"fork":false,"pushed_at":"2024-05-22T08:37:58.000Z","size":141,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-18T21:05:01.777Z","etag":null,"topics":["fetch","fetch-api","javascript","js","wrapper"],"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/RealmTeam.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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-04-06T10:46:23.000Z","updated_at":"2024-05-22T08:38:02.000Z","dependencies_parsed_at":"2024-05-22T09:44:29.474Z","dependency_job_id":null,"html_url":"https://github.com/RealmTeam/easyfetch","commit_stats":null,"previous_names":["philipgarnero/easyfetch"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RealmTeam%2Feasyfetch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RealmTeam%2Feasyfetch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RealmTeam%2Feasyfetch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RealmTeam%2Feasyfetch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RealmTeam","download_url":"https://codeload.github.com/RealmTeam/easyfetch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248129831,"owners_count":21052647,"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","fetch-api","javascript","js","wrapper"],"created_at":"2024-11-06T21:23:17.447Z","updated_at":"2025-04-09T23:31:41.217Z","avatar_url":"https://github.com/RealmTeam.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# easyfetch\n\n[![npm version](https://img.shields.io/npm/v/easyfetch.svg?style=flat-square)](https://www.npmjs.com/package/easyfetch)\n\n`easyfetch` is a simple package that aims to facilitate the use of the default fetch function by wrapping it inside an easy to use api.\n\nIt uses [isomorphic-fetch](https://github.com/matthew-andrews/isomorphic-fetch) to support node.js and non-compatible browsers.\n\n# Getting started\n\n## Install\n\n```sh\n$ npm install --save easyfetch\n```\nor\n\n```sh\n$ yarn add easyfetch\n```\n\n## Api\n\n### `easyFetch(url)`\nIt returns the `EasyFetch` class instance.\n\n### `jsonFetch(url)`\nIt returns the `JsonFetch` class instance.\nIt also adds `Accept` and `Content-Type` headers to : `application/json` and automatically calls `.json()` on the response object returned by the promise.\n\n### `setHeaders(headers)`\nSet headers on the request.\n`headers` is an object.\nIt returns the `EasyFetch` or `JsonFetch` class instance in order to chain calls.\n*Should be called before `_fetch`.*\n\n### `setQueryParams(queryParams)`\nSet query parameters on the url.\n`queryParams` is an object.\nIt returns the `EasyFetch` or `JsonFetch` class instance in order to chain calls.\n*Should be called before `_fetch`.*\n\n### `setOptions(options)`\nSet options for `fetch`.\n`options` is an object.\nIt returns the `EasyFetch` or `JsonFetch` class instance in order to chain calls.\n*Should be called before `_fetch`.*\n\n### `basicAuth(login, password)`\nSet the `Authorization` header to `Basic` with `login` and `password`.\nIt returns the `EasyFetch` or `JsonFetch` class instance in order to chain calls.\n*Should be called before `_fetch`.*\n\n### `head()`\nIt returns the promise returned by `fetch`.\n*Calls `_fetch`.*\n\n### `get()`\nIt returns the promise returned by `fetch`.\n*Calls `_fetch`.*\n\n### `post(body)`\nIt returns the promise returned by `fetch`.\n*Calls `_fetch`.*\n\n### `put(body)`\nIt returns the promise returned by `fetch`.\n*Calls `_fetch`.*\n\n### `patch(body)`\nIt returns the promise returned by `fetch`.\n*Calls `_fetch`.*\n\n### `delete(body)`\nIt returns the promise returned by `fetch`.\n*Calls `_fetch`.*\n\n## Usage Example\n\n```javascript\nimport {easyFetch, jsonFetch} from 'easyfetch'\n\nvar data = {test: \"data\", field: \"test\", field2: 1}\nvar formdata = Object.keys(data).map((k) =\u003e [k, encodeURIComponent(data[k])].join('=')).join('\u0026')\n\neasyFetch(\"https://httpbin.org/get\").get()\n    .then(response =\u003e /* do what you want with the response */)\n    .catch(error =\u003e console.log(error.response))\n\neasyFetch(\"https://httpbin.org/post\")\n    .setHeaders({\"Content-Type\": \"application/x-www-form-urlencoded\"})\n    .post(formdata)\n    .then(response =\u003e response.json())\n    .catch(error =\u003e console.log(\"Request failed: \", error.response))\n    \njsonFetch(\"https://httpbin.org/get\")\n    .setHeaders({'X-Api-Key': config.easyPOSLogApi.apiKey})\n    .get().then(data =\u003e console.log(data))\n\njsonFetch(\"https://httpbin.org/post\").post(data)\n    .then(data =\u003e console.log(data))\n```\n\n# Contributing\n\nFeel free to open issues and submit pull-requests.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frealmteam%2Feasyfetch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frealmteam%2Feasyfetch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frealmteam%2Feasyfetch/lists"}