Guides
Fetching content
List and get entries with the SDK, and understand the response shape.
List entries
const res = await unit.content("articles").list({ limit: 10 })
res.data.forEach((article) => {
console.log(article.attributes.title)
})Get one entry
const article = await unit.content("articles").get("article_123")Response shape
Responses are predictable and versioned. Each entry has an id, a type and an attributes object that matches your schema.
Response
{
"data": [
{
"id": "article_123",
"type": "articles",
"attributes": {
"title": "Welcome to UnitCMS",
"slug": "welcome-to-unitcms"
}
}
],
"meta": { "count": 1 }
}Source metadata
The SDK adds a source field so your UI can react to where the data came from.
| source | Meaning |
|---|---|
network | Fresh from the API |
cache | From the local cache, revalidation in progress or skipped |
offline | The network is unreachable, so the last known content is returned |