Last active
December 11, 2017 11:11
-
-
Save iamkevingreen/208997b3b69e6450e065bfd933bf4d35 to your computer and use it in GitHub Desktop.
This file contains 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
const contentfulAPI = require('./contentful') | |
const shopifyAPI = require('./shopify') | |
const config = require('../config') | |
const buildBlogPost = require('../layouts/article') | |
module.exports = (data) => { | |
const articleId = data.fields.articleId['en-US'] | |
contentfulAPI.getEntries({ | |
content_type: 'passports', | |
'fields.articleId': articleId, | |
include: 8 | |
}).then(({ items }) => { | |
const { fields } = items[0] | |
// Returns Template literals! | |
const createBlogPost = buildBlogPost(fields) | |
shopifyAPI.article.update(config.shopify.blogId, fields.articleId, { | |
title: fields.passportTitle, | |
body_html: createBlogPost, | |
author: fields.author | |
}) | |
.then(res => `Pushed data to shopify!`) | |
.catch(err => console.error(err)) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment