Skip to content

Instantly share code, notes, and snippets.

@kvofreelance
Last active December 31, 2015 17:38
Show Gist options
  • Save kvofreelance/8021201 to your computer and use it in GitHub Desktop.
Save kvofreelance/8021201 to your computer and use it in GitHub Desktop.
parameters = {};
parameters.image = "74dd8e31-d6aa-40dc-a1db-1e2fdf764ba3.jpg";
parameters.name = $scope.title;
parameters.ingredients = [];
parameters.ingredients.push({ingredient: "fat", amount: $scope.totalFat, per: "g"});
parameters.ingredients.push({ingredient: "calories", amount: $scope.calories, per: ""});
parameters.ingredients.push({ingredient: "sodium", amount: $scope.sodium, per: "mg"});
parameters.ingredients.push({ingredient: "protein", amount: $scope.protein, per: "g"});
parameters.ingredients.push({ingredient: "carbohydrate", amount: $scope.totalCarbohydrate, per: "g"});
for (var i = 0; i < $scope.ingridients.length; i++) {
parameters.ingredients.push({ingredient: $scope.ingridients[i]._id, amount: "0", per: scope.ingridients[i].measurement});
}
parameters.description = "";
parameters.category = $scope.category;
parameters.manufacturer = $scope.manufacture;
parameters.region = $scope.city;
$scope.productBarCode = 8802946000258;
$http.post('/barcode/' + $scope.productBarCode, JSON.stringify(parameters))
.success(function (data) {
console.log(JSON.stringify(data));
if ( data.success ){
//alert("Product uploaded successfully.");
console.log(data);
console.log("Product upload successfully.");
}
else {
//alert("Product upload error. ErrorCode: " + data.StatusCode);
console.log("Product upload error. ErrorCode: " + data.StatusCode);
}
})
.error(function (data, status, headers, config) {
console.log(JSON.stringify(data));
//alert("Product upload error. ErrorCode: " + status);
console.log("Product upload error. Status: " + status + "; data: " + data + "; headers: " + headers + "; config: " + config);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment