diff --git a/lib/services/itunes.js b/lib/services/itunes.js index 20cf8dd..4f4fd0a 100644 --- a/lib/services/itunes.js +++ b/lib/services/itunes.js @@ -68,9 +68,9 @@ module.exports.search = function(data) { var path = "/search?term=" + encodeURIComponent(query) + "&media=music&entity=" + entity; request.get(apiRoot + path, function(res) { - var data = JSON.parse(res.text); + var result = JSON.parse(res.text); - if (!data.results[0]) { + if (!result.results[0]) { var matches = album.match(/^[^\(\[]+/); if (matches[0]) { var cleanedData = JSON.parse(JSON.stringify(data)); @@ -84,7 +84,7 @@ module.exports.search = function(data) { deferred.resolve({service: "itunes"}); } } else { - var result = data.results[0]; + var result = result.results[0]; var item = { service: "itunes",