{"id":26208384,"url":"https://github.com/web-pacotes/networking.ts","last_synced_at":"2026-04-08T20:03:01.396Z","repository":{"id":187039572,"uuid":"612883893","full_name":"web-pacotes/networking.ts","owner":"web-pacotes","description":"Yet another fetch based HTTP library :)","archived":false,"fork":false,"pushed_at":"2024-05-24T16:53:50.000Z","size":516,"stargazers_count":0,"open_issues_count":4,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-19T23:15:02.475Z","etag":null,"topics":["angular","fetch","http","httpclient","nodejs","react","svelte","sveltekit","typescript","vue"],"latest_commit_sha":null,"homepage":"https://web-pacotes.github.io/networking.ts/","language":"TypeScript","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/web-pacotes.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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":"2023-03-12T09:15:03.000Z","updated_at":"2024-05-24T16:53:32.000Z","dependencies_parsed_at":"2023-08-08T19:11:25.406Z","dependency_job_id":"555ea582-1fb3-44f3-8a2e-af152cc71145","html_url":"https://github.com/web-pacotes/networking.ts","commit_stats":null,"previous_names":["web-pacotes/networking.ts"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/web-pacotes/networking.ts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/web-pacotes%2Fnetworking.ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/web-pacotes%2Fnetworking.ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/web-pacotes%2Fnetworking.ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/web-pacotes%2Fnetworking.ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/web-pacotes","download_url":"https://codeload.github.com/web-pacotes/networking.ts/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/web-pacotes%2Fnetworking.ts/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31571601,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T14:31:17.711Z","status":"ssl_error","status_checked_at":"2026-04-08T14:31:17.202Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["angular","fetch","http","httpclient","nodejs","react","svelte","sveltekit","typescript","vue"],"created_at":"2025-03-12T06:28:37.482Z","updated_at":"2026-04-08T20:03:01.345Z","avatar_url":"https://github.com/web-pacotes.png","language":"TypeScript","readme":"# networking\n\nYet another fetch based HTTP library :)\n\n![npm version](https://badgen.net/npm/v/@web-pacotes/networking) ![npm total downloads](https://badgen.net/npm/dt/@web-pacotes/networking) ![bundlephobia bundle size](https://badgen.net/bundlephobia/min/@web-pacotes/networking)\n\n---\n\n## How to use\n\nNetworking.ts comes with batteries included, so you can go straight ahead and try some of the existing public API clients. Here's an example on how to consume GitHub RAW API:\n\n```typescript\nconst client = new RawGitHubNetworkingClient({\n\trepository: {\n\t\towner: 'web-pacotes',\n\t\trepo: 'networking.ts',\n\t\tref: 'master'\n\t}\n});\n\n// Get README.md content\nconst getEndpointResult = await client.get({ endpoint: 'README.md' });\n\n// Tadaaaam!\nconsole.info(getEndpointResult);\n```\n\nCreating new clients can either be done by extending the `NetworkingClient` class or manually creating `NetworkingClient` instance:\n\n```typescript\nconst client = new NetworkingClient({\n\tbaseUrl: new URL('https://api.my-awesome-service.com/v1/'),\n\tfetchClient: window.fetch\n});\n\n// Make some requests...\nconst healthResult = await client.get({ endpoint: 'health' });\nconst authenticateResult = await client.post({\n\tendpoint: 'auth',\n\tbody: { username: 'my-username', password: 'oops' }\n});\n\n// extract the result value\nconst hasAuthenticated = fold(\n\tauthenticateResult,\n\t(l) =\u003e false,\n\t(r) =\u003e r.status === 204\n);\n```\n\n### Web Demo\n\nWant to go ahead and try the library on the web? We got you: https://joaomagfreitas.link/demo-networking-ts/\n\n## Features\n\nNetworking.ts aims to be a custom HTTP client library, so it provides designed API functions for the major HTTP methods: `get`, `post`, `put`, `patch` and `delete`. The library also follows a functional style and aims to be side effect free, by replacing all exception/error throws with an `Either` monad. All client functions\nreturn a `Either\u003cHttpRequestError, HttpResponse\u003e` which describes that the result is either an request error or response result. To query the result value you can use the `isLeft`, `isRight` and `fold` functions.\n\n### Fetch Implementation\n\nAnother niche detail about the library, is that it does not rely only on the existing `fetch` implementation. Instead, it allows library clients to pass a `fetch` function that knows how to resolve requests based on the `fetch` spec. This is really neat when making requests in the browser or in Svelte.js, which bundles a custom `fetch` implementation.\n\n### Interceptors\n\nThere is support for interceptors which can act at three levels:\n\n- _request_ level, useful to include mandatory headers before a request is sent to the server.\n- _response_ level, useful to parse the response in a different type before a response is returned to the caller.\n- _request error_ level, useful to log error messages before the error is returned to the caller.\n\nTo create an interceptor you will have to extend either the `Interceptor`, `RequestInterceptor`, `ResponseInterceptor` or `ErrorInterceptor` classes. The major difference in all of them, is that the last ones only describe how to intercept a request/response/request error.\n\nAdditionally, you can make use of the existing `AuthorizationInterceptor` class, which intercepts a request and appends a _basic_ authorization header. Here's how it's useful in the `ImgurNetworkingClient`:\n\n```typescript\nclass ImgurApiAuthorizationInterceptor extends AuthorizationInterceptor {\n\tconstructor(clientId: string) {\n\t\tsuper({\n\t\t\tscheme: 'Client-ID',\n\t\t\tparameters: clientId\n\t\t});\n\t}\n}\n\nexport class ImgurNetworkingClient extends NetworkingClient {\n\tconstructor({\n\t\tclientId,\n\t\tapiVersion,\n\t\tinterceptors,\n\t\tfetchClient,\n\t\ttimeoutMS\n\t}: ImgurNetworkingClientNetworkingClientPositionalProperties) {\n\t\tsuper({\n\t\t\tbaseUrl: resolveUrl('https://api.imgur.com/', apiVersion),\n\t\t\tfetchClient: fetchClient,\n\t\t\ttimeoutMS: timeoutMS,\n\t\t\tinterceptors: [\n\t\t\t\t...(interceptors ?? []),\n\t\t\t\tnew ImgurApiAuthorizationInterceptor(clientId)\n\t\t\t]\n\t\t});\n\t}\n}\n```\n\n### Upcoming features\n\n- client net (a set of clients which each one is chosen to be used with a criteria algorithm, like load-balancing)\n- post form data\n- websocket support\n- response streaming\n- requests redirection follow-up\n\n---\n\n## Bugs and Contributions\n\nFound any bug (including typos) in the package? Do you have any suggestion\nor feature to include for future releases? Please create an issue via\nGitHub in order to track each contribution. Also, pull requests are very\nwelcome!\n\nTo contribute, start by setting up your local development environment. The [setup.md](setup.md) document will onboard you on how to do so!\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweb-pacotes%2Fnetworking.ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweb-pacotes%2Fnetworking.ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweb-pacotes%2Fnetworking.ts/lists"}