vue-data-fetcher

Vue Data Fetcher is a collection of composable functions that provide utility functionalities for common tasks in Vue.js projects. This package is designed to simplify and streamline the development process by encapsulating complex logic into reusable com
1,110
Install
npm install vue-data-fetcher
Latest Version:0.1.5
Vue:3
License:ISC
Last Updated:Jul 16, 2023
Links: npm
Maintainer: ahmeddarwish

Vue Data Fetcher

Vue Data Fetcher is a collection of composable functions that provide utility functionalities for common tasks in Vue.js projects. This package is designed to simplify and streamline the development process by encapsulating complex logic into reusable composable functions.

Installation

You can install the Vue Data Fetcher package via npm:

npm install vue-data-fetcher

Usage

To use the Vue Data Fetcher package in your Vue.js project, you can import the individual composable functions as needed.

Here's an example of how to import and use the useDataFetcherList composable:

<script setup lang="ts">
import apiClient from '@/api/ApiMock'
import type { RolesListResponse, RolesListRequest } from '@/api/ApiTypes'
import { useDataFetcherList } from 'vue-data-fetcher'
const { responseData, loading, error } = useDataFetcherList<RolesListRequest, RolesListResponse>(
  apiClient.rolesList,
  {} as RolesListRequest
)
</script>
<template>
  <h2 class="loading" v-if="loading">loading</h2>
  <h2 v-else-if="error">
    {{ error }}
  </h2>
  <h2 class="response" v-else>{{ JSON.stringify(responseData) }}</h2>
</template>

Here's an example of how to import and use the useDataFetcherFind composable:

<script setup lang="ts">
import apiClient from '@/api/ApiMock'
import type { RoleFindRequest, RoleFindResponse } from '../api/ApiTypes'
import { useDataFetcherFind } from 'vue-data-fetcher'

const { responseData, loading, error } = useDataFetcherFind<RoleFindRequest, RoleFindResponse>(
  apiClient.roleFind,
  'roleId'
)
</script>
<template>
  <h2 class="loading" v-if="loading">loading</h2>
  <h2 v-else-if="error">
    {{ error }}
  </h2>
  <h2 class="response" v-else>{{ JSON.stringify(responseData) }}</h2>
</template>

Related Packages

nuxt-openapi-hyperfetch

Nuxt module for generating an OpenAPI SDK, composables, server routes, and headl...

4,669
@sampullman/vue3-fetch-api

Small fetch wrapper for quickly prototyping API clients

1,178 4
@aspectus/resource

Composable fetch API interface.

3,395
nuxt-api-party

Auto-generated composables for any API, typed from OpenAPI and never exposing yo...

246,965 306
v-api-fetch

Um plugin e composable para Vue 3 que simplifica chamadas de API com Axios, incl...

2,404 3

Version History

Version Released Vue License
0.1.5 ^3.3.4 ISC
0.1.4 ^3.3.4 ISC
0.1.3 ^3.3.4 ISC
0.1.2 ^3.3.4 ISC
0.1.1 ^3.3.4 ISC