A Vue 3 component for making HTTP requests using the native Fetch API. Version 3.0.7 provides a declarative way to fetch data in Vue templates with built-in loading and error states, slot-based rendering, and support for GET/POST/PUT/DELETE methods. It requires Vue 3.0+ and offers a global or local component registration. Compared to axios-based solutions, it leverages the browser's native fetch and targets simplicity for JSON-based REST APIs. It is bundled with Vite and includes a CSS file for styling.
npm install vue3-fetchNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows global registration of the Vue3Fetch component and basic usage with slot props for loading and data.
Ensure the endpoint returns JSON, or handle the error via @fetch-error event.
Add import 'vue3-fetch/dist/style.css' in your main.js or component.
Set headers only for POST/PUT/DELETE as needed; avoid overriding mandatory headers.
Check the URL is correct and the server allows CORS. Ensure the response is valid JSON.
Register the component via app.component('vue3-fetch', Vue3Fetch) in main.js or import and add to components in a SFC.