SR
Click to open github profile
Functions

getCraftData

Learn how to use the getCraftData function.


This function is a fetch wrapper and used internally for all the getCraftQuery functions. You can use this to fetch data from Craft CMS with custom element types or something else. It handles previewing and authorization for you.

Usage

const apiUrl = `?elementType=navigation&handle=mainNavigation&all=1`

const { data, error } = await getCraftData(apiUrl)

Type

export async function getCraftData<ResT = any>(queryUrl: string, options?: RequestInit): Promise<{
    data: ResT | null;
    error: Error | null;
}>

Copyright © 2025 Samuel Reichör