Skip to content

Instantly share code, notes, and snippets.

@chronick
Created January 4, 2017 18:46
Show Gist options
  • Save chronick/609284ba237e703542864aa1f4f1760b to your computer and use it in GitHub Desktop.
Save chronick/609284ba237e703542864aa1f4f1760b to your computer and use it in GitHub Desktop.
"use strict";
const _ = require('lodash');
const Prismic = require('prismic.io');
const Promise = require('bluebird');
function exec() {
return new Promise((resolve, reject) => {
Prismic.api("http://farmlogs-website.prismic.io/api").then(function(api) {
return api.query('[[:d = at(document.type, "team-member")]]');
}).then(function(response) {
const { results } = response;
try {
resolve(_.map(results, ({ data }) => {
return {
image: data["team-member.portrait"].value.main,
name: data["team-member.name"].value,
position: data["team-member.position"].value,
team: data["team-member.team"].value
}
}))
} catch (e) {
console.error(e);
reject(e);
}
}, function(e) {
console.error(e);
reject(e);
});
});
}
if (module.parent) {
module.exports = exec;
} else {
exec().then((data) => console.log(JSON.stringify(data, null, 2)));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment