More sanity checking on passed IDs
This commit is contained in:
parent
a33570e1d0
commit
ff698cff14
4 changed files with 22 additions and 2 deletions
|
@ -19,8 +19,11 @@ module.exports.lookupId = function(id, type) {
|
|||
request.get(apiRoot + path, function(res) {
|
||||
var data = JSON.parse(res.text);
|
||||
|
||||
if (!data.results[0].collectionId) {
|
||||
deferred.resolve({service: "itunes"});
|
||||
if (!data.results || !data.results[0].collectionId) {
|
||||
var error = new Error("Not Found");
|
||||
error.status = 404;
|
||||
deferred.reject(error);
|
||||
return;
|
||||
} else {
|
||||
var result = data.results[0];
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue