Created
January 4, 2017 18:46
-
-
Save chronick/609284ba237e703542864aa1f4f1760b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"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