{"id":13559389,"url":"https://github.com/Fdom92/stencil-fetch","last_synced_at":"2025-04-03T14:32:08.480Z","repository":{"id":51936484,"uuid":"103934268","full_name":"Fdom92/stencil-fetch","owner":"Fdom92","description":"Fetch API implementation with Stenciljs","archived":false,"fork":false,"pushed_at":"2022-12-06T16:39:27.000Z","size":471,"stargazers_count":18,"open_issues_count":7,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-22T20:04:12.781Z","etag":null,"topics":["fetch-api","stenciljs","typescript","web-component"],"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/Fdom92.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":"2017-09-18T12:09:48.000Z","updated_at":"2021-04-06T20:10:24.000Z","dependencies_parsed_at":"2023-01-24T08:31:34.184Z","dependency_job_id":null,"html_url":"https://github.com/Fdom92/stencil-fetch","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/Fdom92%2Fstencil-fetch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fdom92%2Fstencil-fetch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fdom92%2Fstencil-fetch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fdom92%2Fstencil-fetch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Fdom92","download_url":"https://codeload.github.com/Fdom92/stencil-fetch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247018586,"owners_count":20870029,"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":["fetch-api","stenciljs","typescript","web-component"],"created_at":"2024-08-01T13:00:20.771Z","updated_at":"2025-04-03T14:32:08.137Z","avatar_url":"https://github.com/Fdom92.png","language":"JavaScript","funding_links":[],"categories":["Ecosystem Highlights"],"sub_categories":["Utilities \u0026 Integrations"],"readme":"![Built With Stencil](https://img.shields.io/badge/-Built%20With%20Stencil-16161d.svg?logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDE5LjIuMSwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPgo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxheWVyXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IgoJIHZpZXdCb3g9IjAgMCA1MTIgNTEyIiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCA1MTIgNTEyOyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI%2BCjxzdHlsZSB0eXBlPSJ0ZXh0L2NzcyI%2BCgkuc3Qwe2ZpbGw6I0ZGRkZGRjt9Cjwvc3R5bGU%2BCjxwYXRoIGNsYXNzPSJzdDAiIGQ9Ik00MjQuNywzNzMuOWMwLDM3LjYtNTUuMSw2OC42LTkyLjcsNjguNkgxODAuNGMtMzcuOSwwLTkyLjctMzAuNy05Mi43LTY4LjZ2LTMuNmgzMzYuOVYzNzMuOXoiLz4KPHBhdGggY2xhc3M9InN0MCIgZD0iTTQyNC43LDI5Mi4xSDE4MC40Yy0zNy42LDAtOTIuNy0zMS05Mi43LTY4LjZ2LTMuNkgzMzJjMzcuNiwwLDkyLjcsMzEsOTIuNyw2OC42VjI5Mi4xeiIvPgo8cGF0aCBjbGFzcz0ic3QwIiBkPSJNNDI0LjcsMTQxLjdIODcuN3YtMy42YzAtMzcuNiw1NC44LTY4LjYsOTIuNy02OC42SDMzMmMzNy45LDAsOTIuNywzMC43LDkyLjcsNjguNlYxNDEuN3oiLz4KPC9zdmc%2BCg%3D%3D\u0026colorA=16161d\u0026style=flat-square)\n\n# stencil-fetch\n\nstencil-fetch is a web component built with [Stencil](https://stenciljs.com/) that allows you to use the [Fetch API](https://developers.google.com/web/updates/2015/03/introduction-to-fetch).\n\n## Getting Started\n\nTo try this component:\n\n```bash\ngit clone git@github.com:Fdom92/stencil-fetch.git\ncd my-app\ngit remote rm origin\n```\n\nand run:\n\n```bash\nnpm install\nnpm start\n```\n\n## Using this component\n\n### Script tag\n\n- Put `\u003cscript src='https://unpkg.com/stencil-fetch@latest/dist/fetch.js'\u003e\u003c/script\u003e` in the head of your index.html\n- Then you can use the component\n\n### Node Modules\n- Run `npm install stencil-fetch --save`\n- Put a script tag similar to this `\u003cscript src='node_modules/stencil-fetch/dist/fetch.js\u003e\u003c/script\u003e` in the head of your index.html\n- Then you can use the component\n\n### In a stencil-starter app\n- Run `npm install stencil-fetch --save`\n- Add `{ name: 'stencil-fetch' }` to your [collections](https://github.com/ionic-team/stencil-starter/blob/master/stencil.config.js#L5)\n- Then you can use the component\n\n\n## Parameters\n\nAttribute | Default | Description\n------------ | ------------- | -------------\nheaders | {} | Headers for the request\nmethod | 'GET' | The method for the request (GET, POST...)\nurl | '' | The URL to make the request\nbuttonLabel | Fetch | The button label\n\n## Methods\n\nYou can make the request anytime with the method `makeRequest` like this:\n```js\nelement = document.querySelector('st-fetch');\nelement.makeRequest();\n```\n\n## Events\n\nYou can listen for the `resolved` or `error` events like:\n\n```js\nelement = document.querySelector('st-fetch');\nelement.addEventListener('resolved', function(e){console.log(e);})\n```\nAnd you will see the event on the console after ok or error.\n\n### resolved\n\nThis event will be emitted when all goes OK\n\n### error\n\nThis event will be emitted when an error ocurred\n\n## Example\n\nAfter addingthis to your code:\n\n`\u003cst-fetch url=\"https://jsonplaceholder.typicode.com/posts\"\u003e\u003c/st-fetch\u003e`\n\nYou can do this to make a request and get the event:\n\n```js\nelement = document.querySelector('st-fetch');\nelement.addEventListener('resolved', function(event){\n    // Do whatever you want with the event\n});\nelement.addEventListener('error', function(event){\n    // Do whatever you want with the event\n});\nelement.makeRequest();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFdom92%2Fstencil-fetch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FFdom92%2Fstencil-fetch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFdom92%2Fstencil-fetch/lists"}