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 useMyApiData composables also use these defaults, as well as relevant Nuxt configuration set in experimental.defaults. Two options are the exception: client and payloadCache are resolved from the module options for every useMyApiData call, so a default set here reaches $myApi only.

Minimal Example Plugin

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

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

Released under the MIT License.