{"id":13847053,"url":"https://github.com/Icaruk/dame","last_synced_at":"2025-07-12T08:31:16.054Z","repository":{"id":42493759,"uuid":"377452410","full_name":"Icaruk/dame","owner":"Icaruk","description":"dame is a minimalistic HTTP client for the browser and Node.js","archived":false,"fork":false,"pushed_at":"2024-10-27T00:47:24.000Z","size":1120,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-06T04:43:40.032Z","etag":null,"topics":["fetch","http","https","request"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/dame","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Icaruk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2021-06-16T10:07:33.000Z","updated_at":"2024-10-27T00:41:30.000Z","dependencies_parsed_at":"2024-11-21T22:15:40.891Z","dependency_job_id":null,"html_url":"https://github.com/Icaruk/dame","commit_stats":{"total_commits":177,"total_committers":4,"mean_commits":44.25,"dds":"0.10169491525423724","last_synced_commit":"8f442a15e20059fe6f0e10b511c70a7a5ed3ed64"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/Icaruk/dame","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Icaruk%2Fdame","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Icaruk%2Fdame/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Icaruk%2Fdame/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Icaruk%2Fdame/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Icaruk","download_url":"https://codeload.github.com/Icaruk/dame/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Icaruk%2Fdame/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264465889,"owners_count":23612585,"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","http","https","request"],"created_at":"2024-08-04T18:00:53.200Z","updated_at":"2025-07-12T08:31:15.780Z","avatar_url":"https://github.com/Icaruk.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"\n\u003cdiv style=\"text-align:center\"\u003e\n\t\u003ch1\u003e dame \u003c/h1\u003e\n\t\u003cimg height=\"256px\" src=\"https://i.gyazo.com/a3bf515efe3dc7a505dc2d6999c9fefc.png\" /\u003e\n\u003c/div\u003e\n\n\n[![dame package size](https://packagephobia.now.sh/badge?p=dame)](https://packagephobia.now.sh/result?p=dame) [![dame package size minzipped](https://badgen.net/bundlephobia/minzip/dame)](https://badgen.net/bundlephobia/minzip/dame) [![dame dependency count](https://badgen.net/bundlephobia/dependency-count/dame)](https://badgen.net/bundlephobia/dependency-count/dame)\n[![Coverage Status](https://coveralls.io/repos/github/Icaruk/dame/badge.svg?branch=master)](https://coveralls.io/github/Icaruk/dame?branch=master)\n\n\u003cbr\u003e\n\n**dame** minimalistic HTTP client for the browser and Node.js\n\n- 🚀 Lightweight\n- ⚪️ Zero dependencies.\n- 😀 **Easy** to use.\n- 🟢 **Node** (http \u0026 https) and 💻 **browser** (Fetch).\n- 👉 **Promise** API.\n- ⌛ Custom **timeout**.\n- 📄 Automatic transforms to **JSON** data.\n- ⏭ Follows **redirects**.\n\n\u003cbr\u003e\n\n📃 [Changelog](https://github.com/Icaruk/dame/releases)\n\n\n\u003cbr\u003e\u003cbr\u003e\n\n\n\n# Table of contents\n\n\u003c!-- @import \"[TOC]\" {cmd=\"toc\" depthFrom=1 depthTo=6 orderedList=false} --\u003e\n\u003c!-- code_chunk_output --\u003e\n\n- [Table of contents](#table-of-contents)\n- [Import](#import)\n- [Basic examples](#basic-examples)\n- [Response object](#response-object)\n- [Methods](#methods)\n  - [get, delete](#get-delete)\n  - [post, put, patch](#post-put-patch)\n- [Config](#config)\n- [Configuring base instance](#configuring-base-instance)\n- [Creating an instance](#creating-an-instance)\n  - [Examples](#examples)\n  - [Editing an instance](#editing-an-instance)\n- [Special statuses](#special-statuses)\n- [dame vs. others](#dame-vs-others)\n- [☝ Return to top](#a-nametable-of-contentsa-return-to-toptable-of-contents)\n\n\u003c!-- /code_chunk_output --\u003e\n\n\n\n\u003cbr\u003e\u003cbr\u003e\n\n\n\n# Import\n\n```js\nconst dame = require(\"dame\");\n```\n\n\n\n\u003cbr\u003e\u003cbr\u003e\n\n\n\n# Basic examples\n\n**GET**\n```js\nconst {response} = dame.get(\"https://rickandmortyapi.com/api/location/1\");\n```\n\n**POST**\n```js\nconst {response} = dame.post(\"https://your.api.com/login\", {\n\tusername: \"Username\",\n\tpassword: \"****\",\n});\n```\n\n\n\n\u003cbr\u003e\u003cbr\u003e\n\n\n\n# Response object\n\n```js\n{\n\tisError: false,\n\tcode: 200,\n\tstatus: \"OK\",\n\tresponse: {...},\n\terror: null,\n\tredirectCount: 3,\n}\n```\n\n- **isError** `boolean`: True if code is \u003e= 200 and \u003c 300 (this is configurable).\n- **code** `number`: Status code.\n- **status** `string`: Status.\n- **response** `any`: Response of the request.\n- **error** `any`: If there was any error during the request it will be here.\n- **redirectCount** `number`: How many redirects have been followed. Not present if there have been no redirects.\n\n\u003cbr\u003e\n\nThe response can be destructured like this:\n\n\n```js\nconst {isError, code, status, response} = dame.get(\"https://rickandmortyapi.com/api/location/1\");\n```\n\n\n\n\u003cbr\u003e\u003cbr\u003e\n\n\n\n# Methods\n\n## get, delete\n\n```js\nconst {response} = dame.get(url, config);\nconst {response} = dame.delete(url, config);\n```\n\n- **url** `string`: Full URL or path.\n\t- If you set a `baseUrl`, this `url` will be concatenated to it: `baseUrl + url`.\n\t- If `url` starts with `\"http://\"` or `\"https://\"` the `baseUrl` from config will be ignored and url will be treated like a full url.\n- **config** `object`: See [Config](#config).\n\n\n\n\u003cbr\u003e\u003cbr\u003e\n\n\n\n## post, put, patch\n\n```js\nconst {response} = dame.post(url, body, config);\nconst {response} = dame.put(url, body, config);\nconst {response} = dame.patch(url, body, config);\n```\n\n\n- **url** `string`:See [get](#get).\n- **body** `object`: The request body.\n- **config** `object`: See [Config](#config).\n\n\n\n\u003cbr\u003e\u003cbr\u003e\n\n\n\n# Config\n\n- **baseUrl** `string`: Base URL that will be concatenated with the `url` of the requests.\n- **headers** `object`: Headers that will be attached to the request.\n- **timeout** `number`: Number of miliseconds that must pass before timeout the request.\n- **checkIsError** `function\u003cboolean\u003e`: Function that will receive the status code (`number`) and must return `boolean`. Default `isError = !(code \u003e= 200 \u0026\u0026 \u003c 300)`.\n- Any option that fits on [request](https://nodejs.org/api/https.html#https_https_request_url_options_callback) or [fetch](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch).\n- **maxRedirects** `number`: Max redirects to follow. Default 20. Use 0 to disable redirects.\n- **responseType** `\"arraybuffer\" | \"stream\" | \"json\" | \"text\"`: **Browser only**. Default `\"json\"`. Type of the data that the server will respond with.\n\n\n\n\u003cbr\u003e\u003cbr\u003e\n\n\n\n# Configuring base instance\n\n\nSyntax:\n\n```js\ndame.\u003cconfigKey\u003e = \u003cvalue\u003e;\n```\n\n- **configKey**: any key from [Config](#config).\n- **value**: any value that fits on the config key.\n\n\n\nExamples:\n```js\ndame.baseUrl = \"http://localhost:3010\";\ndame.headers.Authorization = `Bearer abcd.1234`;\ndame.timeout = 5000;\n```\n\nThen you'll be able to:\n\n```js\ndame.get(\"/protectedRoute\");\n// url will be → http://localhost:3010/protectedRoute\n// headers will be → {Authorization: \"Bearer abcd.1234\"}\n```\n\n\n\u003cbr\u003e\u003cbr\u003e\n\n\n# Creating an instance\n\n```js\nconst dameInstance = dame.new(config, instanceName?);\n```\n\n- **config** `object`: See [Config](#config).\n- **instanceName** `string`: (optional) If filled, this instance will be saved on `dame.instances.\u003cinstanceName\u003e`.\n\n---\n\nRemoving a saved instance:\n```js\ndelete dame.instances.\u003cinstanceNameToRemove\u003e\n```\n\n\n\n\u003cbr\u003e\n\n\n\n## Examples\n\nSet base URL\n```js\nconst yourApi = dame.new({\n\t\"baseUrl\": \"http://localhost:3000\",\n});\n```\n\nSet headers\n```js\nconst yourApi = dame.new({\n\t\"headers\": {\n\t\tAuthorization: \"Bearer abc.123\"\n\t}\n});\n```\n\n\n\u003cbr\u003e\n\n\n## Editing an instance\n\n```js\nyourApi.headers.Authorization: \"Bearer new.token\";\n```\n\n\n\n\u003cbr\u003e\u003cbr\u003e\n\n\n\n# Special statuses\n\nTimeout\n```js\n{\n\tisError: true,\n\tcode: 0,\n\tstatus: 'Timed out',\n\tresponse: null\n}\n```\n\nNo response\n```js\n{\n\tisError: true,\n\tcode: -1,\n\tstatus: \"No response from server\",\n\tresponse: null\n}\n```\n\nOffline\n```js\n{\n\tisError: true,\n\tcode: -2,\n\tstatus: \"No internet connection\",\n\tresponse: null\n}\n```\n\n\n\n\u003cbr\u003e\u003cbr\u003e\n\n\n\n# dame vs. others\n\n\nPackage | Browser + Node \t\t| Dependencies \t| Size\n:---: \t| :---: \t\t\t\t| :---:\t\t\t| :---:\n**dame** \t|\t✅ | **0** \t| [![dame package size](https://packagephobia.now.sh/badge?p=dame)](https://packagephobia.now.sh/result?p=dame)\nphin \t\t|\t❌ | ![](https://badgen.net/bundlephobia/dependency-count/phin) \t\t| [![phin package size](https://packagephobia.now.sh/badge?p=phin)](https://packagephobia.now.sh/result?p=phin)\nnode-fetch \t|\t❌ | ![](https://badgen.net/bundlephobia/dependency-count/node-fetch) \t| [![node-fetch package size](https://packagephobia.now.sh/badge?p=node-fetch)](https://packagephobia.now.sh/result?p=node-fetch)\naxios \t\t|\t✅ | ![](https://badgen.net/bundlephobia/dependency-count/axios)\t\t| [![axios package size](https://packagephobia.now.sh/badge?p=axios)](https://packagephobia.now.sh/result?p=axios)\ngot \t\t|\t❌ | ![](https://badgen.net/bundlephobia/dependency-count/got) \t\t| [![got package size](https://packagephobia.now.sh/badge?p=got)](https://packagephobia.now.sh/result?p=got)\nsuperagent \t|\t✅ | ![](https://badgen.net/bundlephobia/dependency-count/superagent)\t\t| [![superagent package size](https://packagephobia.now.sh/badge?p=superagent)](https://packagephobia.now.sh/result?p=superagent)\nrequest \t|\t❌ | ![](https://badgen.net/bundlephobia/dependency-count/request) \t\t| [![request package size](https://packagephobia.now.sh/badge?p=request)](https://packagephobia.now.sh/result?p=request)\n\n\n\n\u003cbr\u003e\u003cbr\u003e\n\n\n\n#  \u003ca name='table-of-contents'\u003e\u003c/a\u003e[☝ Return to top](#table-of-contents)\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FIcaruk%2Fdame","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FIcaruk%2Fdame","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FIcaruk%2Fdame/lists"}