Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #6 from Differential/master

check for error before looking at response
  • Loading branch information...
commit ac67bc0399c563fb74896bc72ed6dbe6f87a5ddd 2 parents 20ec800 + 0f14a37
@rgerard authored
View
2  .gitignore
@@ -36,3 +36,5 @@ Thumbs.db
node_modules/
.idea/
+*.sublime-workspace
+*.sublime-project
View
5 index_mlb.js
@@ -77,9 +77,10 @@ function getTeamsHierarchy(callback, event) {
function createRequest(url, callback) {
+
request(url, function (error, response, body) {
- if (response.statusCode == 200) {
+ if (!error && response.statusCode == 200) {
// Parse the XML to JSON
parser.parseString(body, function (err, result) {
@@ -140,4 +141,4 @@ module.exports = {
getTeamsHierarchy: function(callback) {
return getTeamsHierarchy(callback);
}
-};
+};
View
2  index_nba.js
@@ -69,7 +69,7 @@ function getRoster(teamID, callback) {
function createRequest(url, callback) {
request(url, function (error, response, body) {
- if (response.statusCode == 200) {
+ if (!error && response.statusCode == 200) {
// Parse the XML to JSON
parser.parseString(body, function (err, result) {
View
2  index_ncaaf.js
@@ -64,7 +64,7 @@ function getTeamHierarchy(division, callback) {
function createRequest(url, callback) {
request(url, function (error, response, body) {
- if (response.statusCode == 200) {
+ if (!error && response.statusCode == 200) {
// Parse the XML to JSON
parser.parseString(body, function (err, result) {
View
2  index_nfl.js
@@ -119,7 +119,7 @@ function getSeasonalStats(team, callback) {
function createRequest(url, callback) {
request(url, function (error, response, body) {
- if (response.statusCode == 200) {
+ if (!error && response.statusCode == 200) {
// Parse the XML to JSON
parser.parseString(body, function (err, result) {
View
2  index_nhl.js
@@ -49,7 +49,7 @@ function getStandings(callback) {
function createRequest(url, callback) {
request(url, function (error, response, body) {
- if (response.statusCode == 200) {
+ if (!error && response.statusCode == 200) {
// Parse the XML to JSON
parser.parseString(body, function (err, result) {
Please sign in to comment.
Something went wrong with that request. Please try again.