{"id":18547978,"url":"https://github.com/jvanbruegge/minireq","last_synced_at":"2025-04-09T21:32:01.092Z","repository":{"id":41204478,"uuid":"239337900","full_name":"jvanbruegge/minireq","owner":"jvanbruegge","description":"A minimal request library for the browser","archived":false,"fork":false,"pushed_at":"2023-08-03T06:50:14.000Z","size":678,"stargazers_count":45,"open_issues_count":3,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-24T11:56:50.833Z","etag":null,"topics":["browser","hacktoberfest","http-client","typescript","xmlhttprequest"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/jvanbruegge.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":"2020-02-09T16:44:10.000Z","updated_at":"2023-08-08T23:25:55.000Z","dependencies_parsed_at":"2024-11-06T20:36:33.688Z","dependency_job_id":"346c77d2-4c19-41ee-befc-b49b76bcb3a3","html_url":"https://github.com/jvanbruegge/minireq","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/jvanbruegge%2Fminireq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jvanbruegge%2Fminireq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jvanbruegge%2Fminireq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jvanbruegge%2Fminireq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jvanbruegge","download_url":"https://codeload.github.com/jvanbruegge/minireq/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248114770,"owners_count":21050111,"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","hacktoberfest","http-client","typescript","xmlhttprequest"],"created_at":"2024-11-06T20:32:35.118Z","updated_at":"2025-04-09T21:32:00.660Z","avatar_url":"https://github.com/jvanbruegge.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# minireq\n\n![build](https://github.com/jvanbruegge/minireq/workflows/Continous%20Integration/badge.svg) ![docs](https://github.com/jvanbruegge/minireq/workflows/Documentation/badge.svg) [![codecov](https://codecov.io/gh/jvanbruegge/minireq/branch/master/graph/badge.svg)](https://codecov.io/gh/jvanbruegge/minireq) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)\n\nA minimal request library built on XMLHTTPRequest for the browser, and for nodejs with the same API.\n\nDocumentation on [Github Pages](https://jvanbruegge.github.io/minireq/)\n\n## Why not fetch, axios or superagent\n\n`fetch` is too bare bones and also does not support features like progress indication. `axios` and `superagent` are neither minimal nor are they written with ES modules with makes them awkward to bundle.\n\nAlso I want a request library with better types than currently available.\n\n## Example\n\n```ts\nimport { makeRequest } from '@minireq/browser';\n// If you are using nodejs, you can use\n// import { makeRequest } from '@minireq/node';\n\nconst request = makeRequest();\n\nconst { promise, abort } = request({\n    method: 'GET',\n    url: '/api/users',\n});\n\n// Abort on user click\ndocument.querySelector('button.abortRequest').addEventListener('click', () =\u003e {\n    abort();\n});\n\npromise.then(({ status, data }) =\u003e {\n    if (status === 200) {\n        console.log(data.name);\n    }\n});\n```\n\nMaking a post request, with a timeout on 500ms\n\n```ts\nimport { makeRequest } from '@minireq/browser';\n\nconst request = makeRequest();\n\nconst { promise } = request({\n    method: 'POST',\n    url: '/api/users',\n    send: {\n        name: 'Peter',\n        age: 50,\n        children: [],\n    },\n    timeout: 500,\n});\n\npromise.then(({ status, data }) =\u003e {\n    if (status === 201) {\n        console.log(data.id);\n    }\n});\n```\n\nUsing a custom content type\n\n```ts\nimport { makeRequest, defaultSerializers } from '@minireq/browser';\n\nconst serializer = {\n    parse: (data: string) =\u003e data.split('\\n').map(x =\u003e JSON.parse(x)),\n    convert: (data: any) =\u003e {\n        if (!Array.isArray(data)) {\n            return [JSON.stringify(data)];\n        } else {\n            return data.map(x =\u003e JSON.stringify(x)).join('\\n');\n        }\n    },\n};\n\nconst { request } = makeRequest({\n    ...defaultSerializers,\n    'application/ndjson': serializer,\n});\n\nconst { promise, abort } = request({\n    method: 'GET',\n    url: '/api/users',\n    accept: 'application/ndjson',\n});\n\nconst { status, data } = await promise;\n\nif (status === 200) {\n    console.log(data.length);\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjvanbruegge%2Fminireq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjvanbruegge%2Fminireq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjvanbruegge%2Fminireq/lists"}