Skip to content

Instantly share code, notes, and snippets.

@tomblanchard
Last active May 5, 2020 09:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomblanchard/24d07d16da935d1e8aef6e9c469e1db9 to your computer and use it in GitHub Desktop.
Save tomblanchard/24d07d16da935d1e8aef6e9c469e1db9 to your computer and use it in GitHub Desktop.
var express = require('express');
var cors = require('cors');
var Shopify = require('shopify-api-node');
var app = express();
var port = 3000;
// Shopify API
var shopify = new Shopify({
shopName: 'liquify-scripts',
apiKey: '7cb6bb9f126079ff603af945cb4ff2e8',
password: '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'
});
app
// Enable POST params
.use(express.json())
// Enable CORS
.use(cors())
// POST request which creates a product on the fly from POST params
.post('/', (req, res) => {
return shopify.product.create(req.body)
.then((product) => {
return res.json(product);
})
.catch((err) => console.log(err));
})
.listen(port, () => console.log(`Example app listening at http://localhost:${port}`));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment