Overview
Stubby provides you simple api's to fetch data into your next app. You can simply send a post request to the this url
Type | Value |
---|---|
method | GET |
url | https://stubby.io/api/v1/sites/{site_id}/folders |
Parameters
Property | Value | Comment |
---|---|---|
apiKey | string | API key for your site |
Sample code
const STUBBY_CMS_API_KEY = "<API_KEY>";
const siteId = "<YOUR_SITE_ID>";
const url = new URL(`https://stubby.io/api/v1/sites/${siteId}/folders`);
url.searchParams.append("apiKey", STUBBY_CMS_API_KEY);
const res = await fetch(url.href);
const data = await res.json(); // data contains a list of all pages
Response
The response will be sent as a tree structure representing the folder structure you have organized in your app.
[
{
"id": string,
"createdAt": string,
"updatedAt": string,
"parentId": string | null,
"name": string,
"slug": string,
"title": string,
"user": {
"name": string,
"image": string,
"email": string
},
"children": [
{
"id": string,
"createdAt": string,
"updatedAt": string,
"parentId": string | null,
"name": string,
"slug": string,
"title": string,
"metadata": {
[key: string]: any
},
"children": []
}
]
}
]
You can use this data to populate things like side nav, blog posts landing pages etc.