1.0.0 • Published 5 months ago

@noahyu/nuxt-fetch v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

@noahyu/nuxt-fetch

Usage

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

Quick start

// nuxt.config.ts
export default defineNuxtConfig({
  modules: [
    [
      '@noahyu/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, Noah Yu

1.0.0

5 months ago