Skip to content

Instantly share code, notes, and snippets.

@iansu
Created February 12, 2021 17:00
Show Gist options
  • Save iansu/849e7a071e67ceb7511958d50fe7c4f1 to your computer and use it in GitHub Desktop.
Save iansu/849e7a071e67ceb7511958d50fe7c4f1 to your computer and use it in GitHub Desktop.
Butter CMS Integration
import Butter from 'buttercms';
const butter = Butter('api_key');
const getHomePage = async () => {
const homePage = await butter.page.retrieve('*', 'sample-page');
return homePage.data.data;
};
const getPostBySlug = async (slug: string) => {
const page = await butter.post.retrieve(slug);
return page.data.data;
};
const getPosts = async (number: number) => {
const posts = await butter.post.list({ page_size: number });
return posts.data.data;
};
export { getHomePage, getPostBySlug, getPosts };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment