Hi @olivela,
Thanks for reaching out.
Yes, you can get the latest draft from the API, it requires knowing the content ID, so you’d make an extra API Call to get the latest draft, something like:
import { builder } from "@builder.io/react" // or `@builder.io/sdk`
builder.init(process.env.BUILDER_API_KEY)
export async function resolveBuilderContent(modelName: string, userAttributes: Record<string, string | number>, loadLatestDraft = false) {
let page = await builder.get(modelName, { userAttributes }).toPromise();
if (page && loadLatestDraft) {
page = await fetch(`https://builder.io/api/v2/content/${modelName}/${page.id}?apiKey=${apiKey}&preview=true&noCache=true&cachebust=true`).then(res => res.json())
}
return page;
}
To know more you can visit our forum post API parameter to include not yet live content.
Let us know if you have any further questions. Thank you!