{"id":51927814,"url":"https://github.com/ildella/fetch-mpx","last_synced_at":"2026-07-28T04:00:56.856Z","repository":{"id":366871610,"uuid":"1278238815","full_name":"ildella/fetch-mpx","owner":"ildella","description":"Thin client on top of JS/Node fetch","archived":false,"fork":false,"pushed_at":"2026-06-23T17:31:30.000Z","size":70,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-06-23T18:10:17.371Z","etag":null,"topics":["fetch","http","http-client-helper","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/ildella.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-23T15:44:52.000Z","updated_at":"2026-06-23T17:32:04.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/ildella/fetch-mpx","commit_stats":null,"previous_names":["ildella/fetch-mpx"],"tags_count":11,"template":false,"template_full_name":"ildella/lib-template","purl":"pkg:github/ildella/fetch-mpx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ildella%2Ffetch-mpx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ildella%2Ffetch-mpx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ildella%2Ffetch-mpx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ildella%2Ffetch-mpx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ildella","download_url":"https://codeload.github.com/ildella/fetch-mpx/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ildella%2Ffetch-mpx/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35974883,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-07-20T02:08:10.276Z","status":"online","status_checked_at":"2026-07-28T02:00:06.341Z","response_time":109,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["fetch","http","http-client-helper","javascript","nodejs"],"created_at":"2026-07-28T04:00:56.223Z","updated_at":"2026-07-28T04:00:56.833Z","avatar_url":"https://github.com/ildella.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fetch-mpx\n\nA dependency-injected HTTP client with pluggable platform fetch, content-type detection, and error mapping.\n\n- ESM, `\"type\": \"module\"`, Node 22+\n- Yarn 4 (Corepack)\n- Vitest for testing\n- No build step — ships source directly\n- Zero runtime dependencies\n\n## Design\n\n`fetch-mpx` is built around two injected dependencies:\n\n- **`platformFetch(url, options)`** — the actual fetch implementation (browser `fetch`, Node built-in, Tauri's HTTP plugin, etc.)\n- **`mapRequestError(error)`** — converts platform-specific error strings into `Error` objects with `.code` properties\n\nThe library provides optional convenience platform adapters (`platform-browser`, `platform-node`), but the core is completely platform-agnostic.\n\n## Install\n\n```bash\nyarn add fetch-mpx\n```\n\n## Usage\n\n```js\nimport {createHttpClient} from 'fetch-mpx'\n\n// Create a client with your platform fetch\nconst {get, post, put, patch, del, ping} = createHttpClient({\n  platformFetch: fetch,          // browser built-in\n  mapRequestError: error =\u003e error, // pass-through, or your own mapper\n})\n\n// Use it\nconst {data, status, headers} = await get('https://api.example.com/todos/1')\nconst created = await post('https://api.example.com/todos', {title: 'New'})\n```\n\n### With platform adapters\n\n```js\nimport {createHttpClient} from 'fetch-mpx'\nimport {platformFetch} from 'fetch-mpx/platform-node'\n\nconst client = createHttpClient({\n  platformFetch,\n  mapRequestError: error =\u003e error,\n})\n```\n\n### Content-type detection\n\n```js\nimport {detectResponseType, RESPONSE_TYPES} from 'fetch-mpx'\n\ndetectResponseType('application/json')           // 'json'\ndetectResponseType('text/html; charset=utf-8')   // 'text'\ndetectResponseType('audio/mpeg')                 // 'blob'\n```\n\n### Error mapping\n\nThe `mapRequestError` function is called whenever the platform fetch throws a **string** error (e.g. Tauri plugin). It should return an `Error` object.\n\n```js\nconst myErrorMapper = errorString =\u003e {\n  const error = new Error(errorString)\n  error.code = 'CUSTOM_CODE'\n  return error\n}\n\nconst client = createHttpClient({\n  platformFetch,\n  mapRequestError: myErrorMapper,\n})\n```\n\n### Error clarification\n\nSet `clarifyTimeoutError: true` in request config to standardize timeout/abort errors:\n\n```js\ntry {\n  await get(url, {timeout: 5000, clarifyTimeoutError: true})\n} catch (error) {\n  error.name   // 'TimeoutError' or 'AbortError'\n  error.code   // 'TIMEOUT' or 'ABORTED'\n  error.status // 499\n}\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fildella%2Ffetch-mpx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fildella%2Ffetch-mpx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fildella%2Ffetch-mpx/lists"}