Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Latest commit

 

History

History
51 lines (40 loc) · 855 Bytes

README.md

File metadata and controls

51 lines (40 loc) · 855 Bytes

Nuxt Fetch Component

A simple nuxt renderless component wrapper around nuxt fetch capabilities

Installation

yarn add @hammerbot/nuxt-fetch

Usage

<template>
  <div>
    <nuxt-fetch :fetch-fn="fetchFn">
    
      <template #default="{ data, fetching, error }">
        <p>
          {{ data }} - {{ fetching }} - {{ error }}
        </p>
      </template>
      
      <template #fetching>
        Fetching for the first time
      </template>
      
      <template #error="{ error }">
        Error handling {{ error }}
      </template>
      
    </nuxt-fetch>
  </div>
</template>

<script >
import NuxtFetch from '@hammerbot/nuxt-fetch' 

export default {
  components: {
    NuxtFetch
  },
  methods: {
    async fetchFn () {
      const { data } = await this.$api.get('/foo')
      return data
    }
  }
}
</script>