Skip to content

Instantly share code, notes, and snippets.

@iamkevingreen
Last active March 25, 2019 13:46
Show Gist options
  • Save iamkevingreen/70172f8075d68a302c5dc2b55e45e269 to your computer and use it in GitHub Desktop.
Save iamkevingreen/70172f8075d68a302c5dc2b55e45e269 to your computer and use it in GitHub Desktop.
const Prismic = require('prismic.io');
const endpoint = 'https://yourrepo.prismic.io/api';
const CMS = Prismic.api(endpoint);
const cursor = Prismic.Predicates;
class API {
query(key, value) {
return CMS.then((api) => {
return api.query(cursor.at(key, value));
}).then((response) => {
return response;
});
}
queryPaginated(key, value, page, pageSize) {
return CMS.then((api) => {
return api.query(cursor.at(key, value), { page: page, pageSize: pageSize });
}).then((response) => {
return response;
});
}
queryIds(key, value) {
return CMS.then((api) => {
return api.query(cursor.in(key, value));
}).then((response) => {
return response;
})
}
}
export default API;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment