Accessing Node Yelp API - nodedoubt/cinemaplate GitHub Wiki
var yelp = require("node-yelp");
var client = yelp.createClient({
oauth: {
"consumer_key": "xxxxxxxxxxxxxxxxxxxxxxxx",
"consumer_secret": "xxxxxxxxxxxxxxxxxxxxxxxx",
"token": "xxxxxxxxxxxxxxxxxxxxxxxx",
"token_secret": "xxxxxxxxxxxxxxxxxxxxxxxx"
},
});
client.search({
terms: "pizza,
location: "AUSTIN"
}).then(function (data) {
var businesses = data.businesses;
var location = data.region;
}).catch(function (err) {
if (err.type === yelp.errorTypes.areaTooLarge) {
//...
} else if (err.type === yelp.errorTypes.unavailableForLocation) {
// Every error that comes from the module has an id property attached to it
}
});
Error handling -- Every error that comes from the module has an id property attached to it:
var types = { unknown: "UNKNOWN", internal: "INTERNAL_ERROR", exceededRequests: "EXCEEDED_REQS", missingParameter: "MISSING_PARAMETER", invalidParameter: "INVALID_PARAMETER", invalidSignature: "INVALID_SIGNATURE", invalidCredentials: "INVALID_CREDENTIALS", invalidOAuthCredentials: "INVALID_OAUTH_CREDENTIALS", invalidOAuthUser: "INVALID_OAUTH_USER", accountUnconfirmed: "ACCOUNT_UNCONFIRMED", passwordTooLong: "PASSWORD_TOO_LONG", unavailableForLocation: "UNAVAILABLE_FOR_LOCATION", areaTooLarge: "AREA_TOO_LARGE", multipleLocations: "MULTIPLE_LOCATIONS", businessUnavailable: "BUSINESS_UNAVAILABLE", unspecifiedLocation: "UNSPECIFIED_LOCATION" };