preview
Handle preview mode for resources.
await drupal.preview(request, response, options?: { errorMessages?: { secret, slug, }}): Promise<void>
request: NextApiRequest
- Required
- The
request
from an API route.
response: NextApiResponse
- Required
- The
response
from an API route.
options
- Optional
errorMessages
:secret
: The error message to display for an invalid secret.slug
: The error message to display for an invalid slug.
Notes
- The
preview
method should be called in an API route.
Examples
pages/api/preview.ts
import { drupal } from "lib/drupal"
export default async function handler(req, res) { return await drupal.preview(req, res)}