shopify-node
Advanced tools
Comparing version 0.2.1 to 0.2.2
@@ -31,4 +31,8 @@ function ShopifyConnect(params) { | ||
function doReq(opts, d, callback) { | ||
var q = JSON.stringify(d); | ||
var q = null; | ||
if(d) { | ||
q = JSON.stringify(d); | ||
} | ||
if(!opts.method) { | ||
@@ -39,3 +43,3 @@ opts.method = 'get'; | ||
if(opts.method === 'post' || opts.method === 'put' || opts.method === 'delete') { | ||
opts.headers['Content-Length'] = q.length; | ||
opts.headers['Content-Length'] = q ? q.length : 0; | ||
} | ||
@@ -86,4 +90,6 @@ | ||
if(opts.method === 'post' || opts.method === 'put' || opts.method === 'delete') { | ||
req.write(q); | ||
if(q && q.length) { | ||
if (opts.method === 'post' || opts.method === 'put' || opts.method === 'delete') { | ||
req.write(q); | ||
} | ||
} | ||
@@ -176,3 +182,3 @@ | ||
$scope.delete = function(path, data, callback) { | ||
$scope.del = $scope['delete'] = function(path, data, callback) { // need to remove .delete for future versions, will allow it to continue for now. | ||
if(arguments.length < 3) { | ||
@@ -179,0 +185,0 @@ callback = data; |
{ | ||
"name": "shopify-node", | ||
"description": "A NodeJS connector for Shopify OAuth2", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "uh-sem-blee, Co. | typefoo", |
@@ -59,2 +59,3 @@ var prompt = require('prompt'); | ||
} | ||
console.log('GET:'); | ||
console.log(resp); | ||
@@ -88,20 +89,26 @@ }); | ||
} | ||
console.log('POST:'); | ||
console.log(resp); | ||
// PUT | ||
var productData = { | ||
product: { | ||
title: 'Altered Burton Custom Freestyle 151' | ||
} | ||
}; | ||
shopify.put('/admin/products/' + resp.product.id + '.json', productData, function(err, resp) { | ||
if(err) { | ||
return console.log(err); | ||
} | ||
console.log('PUT:'); | ||
console.log(resp); | ||
// DELETE | ||
shopify.delete('/admin/products/' + resp.product.id + '.json', function(err, resp) { | ||
if(err) { | ||
return console.log(err); | ||
} | ||
console.log('DELETE:'); | ||
console.log(resp); | ||
}); | ||
}); | ||
}); | ||
// PUT | ||
shopify.put('/admin/products/1234.json', postData, function(err, resp) { | ||
if(err) { | ||
return console.log(err); | ||
} | ||
console.log(resp); | ||
}); | ||
// DELETE | ||
shopify.delete('/admin/products/1234.json', function(err, resp) { | ||
if(err) { | ||
return console.log(err); | ||
} | ||
console.log(resp); | ||
}); | ||
} |
11086
277