Last active
May 5, 2020 09:35
-
-
Save tomblanchard/24d07d16da935d1e8aef6e9c469e1db9 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
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