-
Notifications
You must be signed in to change notification settings - Fork 190
Open
Labels
Description
Implement Strapi Client SDK in Launchpad.
Replace the fetch implementation in the fetchContentType.ts file and instead use Strapi Client SDK based on the following package.
Should support both pubic and authenticated requests.
Basic Example:
Client Setup
import { strapi } from '@strapi/client';
import { getStrapiURL } from "@/lib/utils";
const BASE_API_URL = getStrapiURL() + "/api";
const sdk = strapi({ baseURL: BASE_API_URL });
// Helper to get authenticated SDK collection
const getAuthenticatedCollection = (collectionName: string, jwt: string) => {
const authenticatedSdk = strapi({
baseURL: BASE_API_URL,
auth: jwt,
})
return authenticatedSdk.collection(collectionName)
}
export { sdk, getAuthenticatedCollection };Basic usage ( public access )
const response = await sdk.single('landing-page').find()
return { data: response.data as TLandingPage }Basic usage ( auth )
import { getAuthenticatedCollection, sdk } from '@/data/strapi-sdk'
const authenticatedComments = getAuthenticatedCollection('comments', jwt)
return authenticatedComments.update(commentDocumentId, {
content: commentData.content,
}) as Promise<TCommentSingleResponse>These are just some basic idea examples, but the goal is to have Strapi Client support both pubic and auth request.