Created
June 6, 2018 14:30
-
-
Save stefanoverna/09fa06630f9193381040512b5fddccb0 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 { SiteClient } = require('datocms-client'); | |
const client = new SiteClient('YOUR-API-TOKEN'); | |
const config = require('./gatsby-config'); | |
config.siteMetadata.products.reduce((chain, product) => ( | |
chain | |
.then(() => client.uploadImage(product.image)) | |
.then((image) => client.items.create({ | |
name: product.name, | |
image: image, | |
price: product.price, | |
itemType: 'YOUR-MODEL-ID', | |
})) | |
), Promise.resolve()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment