Skip to content

Defaults

Set default options for Nuxt API Party $myApi composables in a Nuxt plugin. Provide the apiParty key with a defaults and/or endpoints.[endpointId].defaults object.

  • defaults defines global defaults for all endpoints
  • endpoints.[endpointId].defaults defines defaults for a specific endpoint (overrides global defaults)

The ModulePlugin type ensures your plugin provides correct defaults.

Inheritance

The useApiData composables also use these defaults, as well as relevant Nuxt configuration set in experimental.defaults.

Minimal Example Plugin

ts
import type { ModulePlugin as APIPartyPlugin } from 'nuxt-api-party'

export default defineNuxtPlugin(() => {
  return {
    provide: {
      apiParty: {
        defaults: {
          // ...
        },
        endpoints: {
          [endpointId]: {
            defaults: {
              // ...
            }
          }
        }
      }
    }
  }
}) satisfies APIPartyPlugin

Released under the MIT License.