@spruce-hub/nuxt-fetch
TypeScript icon, indicating that this package has built-in type declarations

1.11.1 • Public • Published

@spruce-hub/nuxt-fetch

Usage

npm install @spruce-hub/nuxt-fetch --save
# or
pnpm add @spruce-hub/nuxt-fetch -P

Quick start

// nuxt.config.ts
export default defineNuxtConfig({
  modules: [
    [
      '@spruce-hub/nuxt-fetch',
      {
        '/api': {
          pathRewrite: {
            '^/api': 'api',
          },
          apiHostEnv: 'API_HOST',
          apiHostUrl: 'http://api.com',
          cookieName: 'access_token',
        },
        '/api2': {
          pathRewrite: {
            '^/api2': '/api',
          },
          apiHostEnv: 'API_HOST',
          apiHostUrl: 'http://api2.com',
          cookieName: 'access_token',
        },
      },
    ],
  ],
})
const { data, pending, error, refresh } = await useFetch('/api/example')

// http://localhost/api/example => http://myapi.com/api/example

License

MIT

Copyright (c) 2023-present, Spruce FE

Package Sidebar

Install

npm i @spruce-hub/nuxt-fetch

Weekly Downloads

0

Version

1.11.1

License

MIT

Unpacked Size

7.83 kB

Total Files

13

Last publish

Collaborators

  • zzl821
  • z812032622
  • wenzheng-yi