{"id":13548290,"url":"https://github.com/vaheqelyan/karin","last_synced_at":"2025-04-05T23:12:01.098Z","repository":{"id":57288343,"uuid":"163268503","full_name":"vaheqelyan/karin","owner":"vaheqelyan","description":"An elegant promise based HTTP client for the browser and node.js [WIP]","archived":false,"fork":false,"pushed_at":"2019-02-09T07:37:01.000Z","size":1801,"stargazers_count":392,"open_issues_count":0,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-29T22:08:52.172Z","etag":null,"topics":["browser","http-client","http-requests","javascript","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/vaheqelyan.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-12-27T08:27:43.000Z","updated_at":"2025-02-28T03:02:20.000Z","dependencies_parsed_at":"2022-09-01T03:52:34.937Z","dependency_job_id":null,"html_url":"https://github.com/vaheqelyan/karin","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vaheqelyan%2Fkarin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vaheqelyan%2Fkarin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vaheqelyan%2Fkarin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vaheqelyan%2Fkarin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vaheqelyan","download_url":"https://codeload.github.com/vaheqelyan/karin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247411239,"owners_count":20934653,"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":["browser","http-client","http-requests","javascript","nodejs"],"created_at":"2024-08-01T12:01:08.324Z","updated_at":"2025-04-05T23:12:01.067Z","avatar_url":"https://github.com/vaheqelyan.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","Libraries"],"sub_categories":["HTTP"],"readme":"\n# Karin\n\n\u003cp\u003e\n  \u003ca href=\"https://travis-ci.org/vaheqelyan/karin\"\u003e\u003cimg src=\"https://travis-ci.org/vaheqelyan/karin.svg?branch=master\"/\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/karin\"\u003e\u003cimg  src=\"https://img.shields.io/npm/v/karin.svg\"/\u003e\u003c/a\u003e\n\u003ca href=\"#\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/node-\u003e=4.9.1-brightgreen.svg\"/\u003e\n\u003c/a\u003e\n\u003ca href=\"https://bundlephobia.com/result?p=karin@latest\"\u003e\u003cimg src=\"https://img.shields.io/bundlephobia/minzip/karin.svg?style=flat-square\"/\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cimg src=\"https://res.cloudinary.com/dmtrk3yns/image/upload/q_auto/v1546696886/carbon_4_w0jdqr.png\"/\u003e\n\n## About\n\nTemplate literals are very useful. A more advanced form of template literals are tagged templates. Karin works in all major browsers (Chrome, Firefox, IE, Edge, Safari, and Opera). Modern browsers and JavaScript engines support tag templates. It is also compatible with Node.js.\n**The package uses the Fetch API, make sure you have a polyfill to support older browsers**. Recommend to use [github/fetch](https://github.com/github/fetch)\n\ne.g.\n```jsx\nimport React from \"react\";\nimport { get } from \"karin\";\n\nexport default class Index extends React.Component {\n  static async getInitialProps() {\n    const { data, response } = await get`https://api.github.com/repos/zeit/next.js`;\n    return { stars: data.stargazers_count };\n  }\n\n  render() {\n    return (\n      \u003cdiv\u003e\n        \u003cp\u003e {this.props.stars} ⭐️\u003c/p\u003e\n      \u003c/div\u003e\n    );\n  }\n}\n```\n\n## Installation\n\n**via NPM**\n\n```code\nnpm i karin\n```\n\n**via CDN (unpkg)**\n\n```code\nhttps://unpkg.com/karin@latest/build/browser/index.umd.js\n```\n\nUMD library exposed as Karin\n\n```js\nconst { get, post } = Karin;\n```\n\nImport paths\n\n```js\nimport { get, post } from \"karin/build/node\";\nimport { get, post } from \"karin/build/browser/index.umd.js\";\n```\n\n## Make a get request\n\nThe response data - By default, if the response data type is Application/JSON, the response will be parsed into JSON\n\n```js\nimport { get } from \"karin\";\n\nget`https://api.github.com/repos/vaheqelyan/karin`\n  .then(result =\u003e console.log(result))\n  .catch(err =\u003e console.error(err));\n```\n\n## Make a post request\n\nThe post data - If the data is an object, it will be stringified\n\nThe response data - By default, if the response data type is application/json, the response will be parsed into JSON\n\n**Note** that the data to be sent is the last item.\n\n```js\nimport { post } from \"karin\";\n\nconst user = {\n  username: \"vaheqelyan\",\n  password: \"XXXX\"\n};\n\npost`http://localhost:3000/register ${user}`\n  .then(result =\u003e console.log(result))\n  .catch(err =\u003e console.log(err));\n```\n\n## Add Header in HTTP Request\n\n```js\npost`https://example.com/api.createMsg?${{apiKey: config.apiKey}}\nContent-Type: application/json\nAccept: application/json\nXXX: xxx\n\n${{\n  title: 'Test Message',\n  body: 'This is a test of the messaging system.'\n}}`\n```\nThanks to [Ken Bellows](https://dev.to/kenbellows/comment/83m6) for the idea.\n\nSee Version [0.11.1](https://github.com/vaheqelyan/karin/tree/v0.11.1) for old syntax\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvaheqelyan%2Fkarin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvaheqelyan%2Fkarin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvaheqelyan%2Fkarin/lists"}