Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements on error handling in forecastio and instagram nodes #140

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
4 changes: 2 additions & 2 deletions forecast/forecastio.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ module.exports = function(RED) {
}

if (90 >= lat && 180 >= lon && lat >= -90 && lon >= -180) {
node.lat = lat;
node.lon = lon;
node.lat = lat.trim();
node.lon = lon.trim();
} else {
return callback(RED._("forecastio.error.invalid-lat_lon"));
}
Expand Down
14 changes: 10 additions & 4 deletions instagram/instagram.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,10 @@ module.exports = function(RED) {
node.ig.user_media_recent('self', { count : 1, min_id : null, max_id : null}, function(err, medias, pagination, remaining, limit) {
if (err) {
node.warn(RED._("instagram.warn.userphoto-fetch-fail", {err: err}));
return;
}

if(medias.length > 0) { // if the user has uploaded something to Instagram already
if(typeof medias !== 'undefined' && medias.length > 0) { // if the user has uploaded something to Instagram already
node.latestSelfContentID = medias[0].id;
}

Expand All @@ -97,9 +98,10 @@ module.exports = function(RED) {
node.ig.user_self_liked({ count : 1, max_like_id : null}, function(err, medias, pagination, remaining, limit) {
if (err) {
node.warn(RED._("instagram.warn.likedphoto-fetch-fail", {err: err}));
return;
}

if(medias.length > 0) { // if the user has liked something to Instagram already
if(typeof medias !== 'undefined' && medias.length > 0) { // if the user has liked something to Instagram already
node.latestLikedID = medias[0].id;
}

Expand All @@ -120,8 +122,9 @@ module.exports = function(RED) {
node.ig.user_media_recent('self', { count : 1, min_id : null, max_id : null}, function(err, medias, pagination, remaining, limit) {
if (err) {
node.warn(RED._("instagram.warn.userphoto-fetch-fail", {err: err}));
return;
}
if(medias.length > 0) { // if the user has uploaded something to Instagram already
if(typeof medias !== 'undefined' && medias.length > 0) { // if the user has uploaded something to Instagram already
if(medias[0].type === IMAGE) {
if(medias[0].location) {
if(medias[0].location.latitude) {
Expand Down Expand Up @@ -172,8 +175,9 @@ module.exports = function(RED) {
node.ig.user_self_liked({ count : 1, max_like_id : null}, function(err, medias, pagination, remaining, limit) {
if (err) {
node.warn(RED._("instagram.warn.likedphoto-fetch-fail", {err: err}));
return;
}
if(medias.length > 0) { // if the user has liked something to Instagram already
if(typeof medias !== 'undefined' && medias.length > 0) { // if the user has liked something to Instagram already
if(medias[0].type === IMAGE) {
if(medias[0].location) {
if(medias[0].location.latitude) {
Expand Down Expand Up @@ -235,6 +239,7 @@ module.exports = function(RED) {

if (err) {
node.warn(RED._("instagram.warn.latest-media-fetch-failed", {err: err}));
return;
}

if(medias) {
Expand Down Expand Up @@ -401,6 +406,7 @@ module.exports = function(RED) {
client_id: credentials.client_id,
redirect_uri: credentials.redirect_uri,
response_type: "code",
scope: "public_content",
state: node_id + ":" + credentials.csrfToken
}
}));
Expand Down
6 changes: 3 additions & 3 deletions instagram/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name" : "node-red-node-instagram",
"version" : "0.1.0",
"version" : "0.1.1",
"description" : "Node-RED nodes that get photos from Instagram",
"dependencies" : {
"request":"~2.40.0",
"instagram-node":"0.5.1"
"instagram-node":"0.5.8"
},
"repository" : {
"type":"git",
Expand All @@ -22,4 +22,4 @@
"email": "[email protected]",
"url": "http://nodered.org"
}
}
}