{"id":18941570,"url":"https://github.com/bahrus/k-fetch","last_synced_at":"2026-05-16T11:03:12.482Z","repository":{"id":57287878,"uuid":"320681654","full_name":"bahrus/k-fetch","owner":"bahrus","description":"k-fetch is a small, bare-bones simple fetch web component.","archived":false,"fork":false,"pushed_at":"2024-03-09T12:08:51.000Z","size":330,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"baseline","last_synced_at":"2025-09-17T21:44:11.157Z","etag":null,"topics":["custom-element","custom-elements","custom-elements-v1","web-component","web-components"],"latest_commit_sha":null,"homepage":"https://jsfiddle.net/bahrus/ma0vtbnx/2/","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/bahrus.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}},"created_at":"2020-12-11T20:53:00.000Z","updated_at":"2024-03-07T04:47:19.000Z","dependencies_parsed_at":"2024-11-19T21:40:48.423Z","dependency_job_id":null,"html_url":"https://github.com/bahrus/k-fetch","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bahrus/k-fetch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahrus%2Fk-fetch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahrus%2Fk-fetch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahrus%2Fk-fetch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahrus%2Fk-fetch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bahrus","download_url":"https://codeload.github.com/bahrus/k-fetch/tar.gz/refs/heads/baseline","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahrus%2Fk-fetch/sbom","scorecard":{"id":223673,"data":{"date":"2025-08-11","repo":{"name":"github.com/bahrus/k-fetch","commit":"42a155104011dca91832afe0a4d1722e89cb4680"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.4,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'baseline'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":5,"reason":"5 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-76c9-3jph-rj3q","Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-17T03:10:33.944Z","repository_id":57287878,"created_at":"2025-08-17T03:10:33.944Z","updated_at":"2025-08-17T03:10:33.944Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279008623,"owners_count":26084480,"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","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"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":["custom-element","custom-elements","custom-elements-v1","web-component","web-components"],"created_at":"2024-11-08T12:28:35.494Z","updated_at":"2025-10-11T20:40:21.334Z","avatar_url":"https://github.com/bahrus.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ca href=\"https://nodei.co/npm/k-fetch/\"\u003e\u003cimg src=\"https://nodei.co/npm/p-fetch.png\"\u003e\u003c/a\u003e\n# k-fetch\n\n[![NPM version](https://badge.fury.io/js/k-fetch.png)](http://badge.fury.io/js/k-fetch)\n[![How big is this package in your project?](https://img.shields.io/bundlephobia/minzip/k-fetch?style=for-the-badge)](https://bundlephobia.com/result?p=k-fetch)\n\u003cimg src=\"http://img.badgesize.io/https://cdn.jsdelivr.net/npm/k-fetch?compression=gzip\"\u003e\n\u003c!--[![Playwright Tests](https://github.com/bahrus/k-fetch/actions/workflows/CI.yml/badge.svg?branch=baseline)](https://github.com/bahrus/k-fetch/actions/workflows/CI.yml)--\u003e\n\n\n## [Demo](https://jsfiddle.net/bahrus/ma0vtbnx/1/)\n\nk-fetch is a small, bare-bones simple fetch web component.  For more features (but larger footprint), see [xtal-fetch](https://www.npmjs.com/package/xtal-fetch). k-fetch provides no support for rendering while streaming.  For such support, see alternatives, such as [be-written](https://github.com/bahrus/be-written).\n\nk-fetch can act as a base web component for \"web components as a service\".  [be-kvetching](https://github.com/bahrus/be-kvetching) and [be-fetching](https://github.com/bahrus/be-fetching) [TODO] actually do just that - they can dynamically create such a web component on the fly, declaratively, that extends this base class.\n\nMarkup:\n\n```html\n\u003ck-fetch \nhref=https://cors-anywhere.herokuapp.com/https://www.theonion.com/ \nas=html shadow=open onerror=\"console.error(href)\"\u003e\u003c/k-fetch\u003e\n    \n```\n\nFor this very specific example shown above, due to restrictions of the cors-anywhere utility the link above uses, you will first need to go to https://cors-anywhere.herokuapp.com/corsdemo to unlock the service for a limited amount of time.\n\nRequired attributes are href and at least one of these attributes: onerror, oninput, onload, onchange.  The reason for insisting on at least one of these on* attributes is this:  Since these attributes can't pass through any decent sanitizer that prevents xss attacks, the presence of one or more of them indicates that the web site trusts the content from which the data is being retrieved.\n\nWhen the fetch is complete, event \"load\" is fired, which can allow for manipulation of the data.  The (modified) data is then stored in the \"value\" field of the k-fetch (or subclassed) instance. Also, event \"change\" is fired. \n\nIf as=html, the response is inserted into the innerHTML of the k-fetch element, unless attribute shadow is present, in which case it will first create a shadowRoot, then insert the innerHTML.\n\nk-fetch has no support for \"href\" or \"as\" properties, only attributes.\n\nk-fetch caches get's based on the localName of the custom element as the base key of the cache. \n\n## Sending data to a target:\n\n```html\n\u003ck-fetch \n    href=https://newton.now.sh/api/v2/integrate/x^2 \n    target=json-viewer[-object]\n    onerror=console.error(href)\n\u003e\n\u003c/k-fetch\u003e\n...\n\u003cjson-viewer -object\u003e\u003c/json-viewer\u003e\n```\n\nk-fetch will set aria-busy to true while fetch is in progress, and also set aria-live=polite if no aria-live value is found.\n\n## Viewing Demos Locally\n\nAny web server that can serve static files will do, but...\n\n1.  Install git.\n2.  Fork/clone this repo.\n3.  Install node.js.\n4.  Open command window to folder where you cloned this repo.\n5.  \u003e npm install\n6.  \u003e npm run serve\n7.  Open http://localhost:8000 in a modern browser.\n\n\u003c!--## Running Tests\n\n```\n\u003e npm run test\n```\n--\u003e\n## Using from ESM Module:\n\n```JavaScript\nimport 'k-fetch/k-fetch.js';\n```\n\n## Using from CDN:\n\n```html\n\u003cscript type=module crossorigin=anonymous\u003e\n    import 'https://esm.run/k-fetch';\n\u003c/script\u003e\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbahrus%2Fk-fetch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbahrus%2Fk-fetch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbahrus%2Fk-fetch/lists"}