{"id":17972340,"url":"https://github.com/vasanthv/fetch-lite","last_synced_at":"2025-03-25T12:32:56.706Z","repository":{"id":57234655,"uuid":"123941419","full_name":"vasanthv/fetch-lite","owner":"vasanthv","description":"A lightweight module to send HTTP(s) requests from Node.js.","archived":true,"fork":false,"pushed_at":"2019-09-13T10:08:26.000Z","size":20,"stargazers_count":41,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-01T21:45:43.852Z","etag":null,"topics":["curl","fetch","fetch-api","http-client","http-request","nodejs"],"latest_commit_sha":null,"homepage":"","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/vasanthv.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":"2018-03-05T15:43:32.000Z","updated_at":"2025-01-21T21:13:48.000Z","dependencies_parsed_at":"2022-09-15T04:22:23.435Z","dependency_job_id":null,"html_url":"https://github.com/vasanthv/fetch-lite","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/vasanthv%2Ffetch-lite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vasanthv%2Ffetch-lite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vasanthv%2Ffetch-lite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vasanthv%2Ffetch-lite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vasanthv","download_url":"https://codeload.github.com/vasanthv/fetch-lite/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245462937,"owners_count":20619581,"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":["curl","fetch","fetch-api","http-client","http-request","nodejs"],"created_at":"2024-10-29T16:12:30.887Z","updated_at":"2025-03-25T12:32:56.451Z","avatar_url":"https://github.com/vasanthv.png","language":"JavaScript","readme":"[![Build Status](https://travis-ci.org/vasanthv/fetch-lite.svg?branch=master)](https://travis-ci.org/vasanthv/fetch-lite)\n\n# fetch-lite\n\u003e A lightweight module to send HTTP(s) requests from Node.js.  \n\n- Not dependent on any third party modules. \n- Purely based on Node.Js `http.request` client.\n- Written in less than **30** lines. 😳\n- Implements just the fetch() function and nothing else.\n- Returns *Promise* (so works with *async/await*).\n\n\u003e Whats missing?   \n\u003e - File Upload (multipart/form-data)  \n\u003e - Streaming.   \n\n## Install\nInstall using [npm](https://npmjs.com/).\n```\nnpm install --save fetch-lite\n```\n\n*OR*\nUsing [yarn](https://yarnpkg.com/).\n```\nyarn install --save fetch-lite\n```\n\n## Usage\nThe idea of fetch-lite is to create a minimal version of  `fetch()` API  described [here](https://fetch.spec.whatwg.org/#fetch-api).  A basic GET request is shown below.\n\n```js\nconst fetch = require('fetch-lite');\n\nfetch('https://httpbin.org/get')\n.then(response =\u003e console.log(response))\n.catch(err =\u003e console.error(err));\n```\n\nUsing async/await.\n```js\n(async () =\u003e {\n    const response = await fetch('https://httpbin.org/get');\n    console.log(response);\n})();\n```\n\n\n### Post\nPosting a post body.\n```js\nfetch('http://httpbin.org/post', {\n    method: 'POST',\n    body: {\n        hello: 'world'\n    }\n})\n.then(response =\u003e console.log(response))\n.catch(err =\u003e console.error(err));\n```\n\nPosting a JSON body.\n```js\nfetch('http://httpbin.org/post', {\n    method: 'POST',\n    body: {\n        hello: 'world'\n    },\n    headers: {\n        'content-type': 'application/json'\n    }\n})\n.then(response =\u003e console.log(response))\n.catch(err =\u003e console.error(err));\n```\n\nPosting a Buffer.\n```js\nfetch('http://httpbin.org/post', {\n    method: 'POST',\n    body: Buffer.from(\"Hello World\")\n})\n.then(response =\u003e console.log(response))\n.catch(err =\u003e console.error(err));\n```\n\n### Basic auth\n```js\nfetch('https://httpbin.org/basic-auth/user/passwd', {\n    auth: \"user:passwd\"\n})\n.then(response =\u003e assertEq(response.status, 200))\n.catch(err =\u003e breakWithErr(err));\n```\n\n## API\nThe module export one function which accepts only 2 params.\n1. URL. String *(Required)*\n2. Options. Object. *(Optional)*\n\t- method. String. (POST | GET | PUT etc). *Default GET*.\n\t- body. String or [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) or [Buffer](https://nodejs.org/api/buffer.html).\n\t- headers. [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object).\n\t- auth. String. Used to set the Basic auth header. Format *\"username/password\"*.\n\t- followredirect. Boolean. *Default True*.\n\n**Output Params:**\n- headers. [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)\n- statusText. String\n- status. Number\n- url. String\n- body. String or [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)\n\n\n## Licence\nMIT","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvasanthv%2Ffetch-lite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvasanthv%2Ffetch-lite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvasanthv%2Ffetch-lite/lists"}