loadSlotContent
Learn how to asynchronously retrieve default slot content.
This function asynchronously retrieves the default content for a Slot from the @croct/content package.
Lazy loading
When using bundlers that support code splitting, prefer this function over its sync counterpart, as it enables lazy loading of content modules.
Signature
This function has the following signature:
loadSlotContent(slotId: string, language?: string): Promise<JsonObject | null>The return is a Promise that resolves to the content as a JSON object, or null if no content is available for the given slot and locale.
Example
Here is a minimal example of how to use this function:
1234567
import {loadSlotContent} from '@croct/content';
const content = await loadSlotContent('home-hero');
if (content !== null) { console.log(content.title);}Parameters
The following list describes the supported parameters: