UNPKG

nuxt

Version:

Nuxt is a free and open-source framework with an intuitive and extendable way to create type-safe, performant and production-grade full-stack web applications and websites with Vue.js.

61 lines (60 loc) 2.5 kB
import { docsBase, prodReporters, reporters } from "./_shared.js"; import { defineDiagnostics, defineProdDiagnostics } from "nostics"; //#region src/app/diagnostics/data.ts /** * E3xxx * Data fetching (useFetch / useAsyncData) runtime diagnostics. */ const dataDiagnostics = !import.meta.dev ? /* #__PURE__ */ defineProdDiagnostics({ docsBase, reporters: prodReporters }) : /* #__PURE__ */ defineDiagnostics({ docsBase, reporters, codes: { NUXT_E3001: { why: (p) => `The \`useFetch\` request URL must not start with "//" (received \`${p.url}\`).`, fix: "Use an absolute URL with a protocol or a relative path instead." }, NUXT_E3002: { why: "`useFetch` failed to hash the request body for the cache key.", fix: "Pass a serializable value (plain object, string, FormData) as the request body, or provide an explicit `key` to `useFetch`.", docs: false }, NUXT_E3003: { why: "`useAsyncData`/`useFetch` was called after the component had already mounted, so the data fetch cannot be awaited during setup.", fix: "Use `$fetch()` for requests triggered after mount (e.g. in event handlers), or call `useAsyncData`/`useFetch` in the `setup()` function.", docs: false }, NUXT_E3004: { why: (p) => `Incompatible options detected for "${p.key}":\n${p.warnings}`, fix: "You can use a different key or move the call to a composable to ensure the options are shared across calls.", docs: false }, NUXT_E3005: { why: "`execute` was passed directly to `watch`, which causes unintended behavior.", fix: "Wrap the call: `watch(source, () => execute())` instead of `watch(source, execute)`.", docs: false }, NUXT_E3006: { why: (p) => `\`${p.fn}\` handler returned \`undefined\`, so the request may be duplicated on the client side.`, fix: "Return a value from the handler function (e.g. `return null` instead of returning nothing).", docs: false }, NUXT_E3007: { why: "`asyncData` returned a non-object value.", fix: "Return a plain object from the `asyncData()` function, e.g. `asyncData() { return { key: value } }`.", docs: false }, NUXT_E3008: { why: "`useAsyncData` key must be a non-empty string.", fix: "Pass a non-empty string as the first argument to `useAsyncData()`." }, NUXT_E3009: { why: "`useAsyncData` handler must be a function.", fix: "Pass a function as the handler argument, e.g. `useAsyncData('key', () => $fetch('/api/data'))`." } } }); //#endregion export { dataDiagnostics };