1.0.1 • Published 11 years ago
wineapi v1.0.1
WineApi
Provides a fluent API for building URL's for Wine.com's API.
Links
Installation
npm install WineApi
Example
var $ = require("jquery");
var WineApi = require("WineApi");
var wineApi = new WineApi("insert-your-key-here");
var url = wineApi.catalogService()
.categoriesFilter(124)
.search("gamay")
.state("CA")
.instock()
.url();
console.log("Invoking wine.com catalog service...");
$.ajax({
dataType: "json",
url: url,
success: function (data) {
if (data.Status.ReturnCode === 0) {
console.log("Products.Total: " + data.Products.Total);
for (var productIndex = 0; productIndex < data.Products.List.length; productIndex++) {
console.log("\t" + data.Products.List[productIndex].Name);
}
} else {
for (var messageIndex = 0; messageIndex < data.Status.Messages.length; messageIndex++) {
console.log(data.Status.Messages[messageIndex]);
}
}
},
error: function (xhr, typeOfError, httpStatusText) {
console.log("An error occurred invoking the wine.com catalog service");
console.log("typeOfError: " + typeOfError);
if (httpStatusText) {
console.log("httpStatusText: " + httpStatusText);
}
}
});
1.0.1
11 years ago