From a4aceed85d7b301140df13cdc450fdd32f79bc66 Mon Sep 17 00:00:00 2001 From: Victor Akinwande Date: Wed, 22 Jul 2015 16:16:51 +0100 Subject: [PATCH 1/4] Changed the parse options variable "host" field to "hostname" I read somewhere that this is better and it has personally prevented the "[Error: getaddrinfo ENOTFOUND api.parse.com]" error I get occasionally. --- lib/Parse.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Parse.js b/lib/Parse.js index 18f6d40..018448c 100644 --- a/lib/Parse.js +++ b/lib/Parse.js @@ -395,7 +395,7 @@ function parseRequest(method, path, data, callback, contentType, sessionToken) { } var options = { - host: this._api_host, + hostname: this._api_host, port: this._api_port, headers: headers, path: path, From 6d5509b2e1cb88203cc8d2006abc9cab2ede469c Mon Sep 17 00:00:00 2001 From: Victor Date: Mon, 27 Jul 2015 18:07:17 +0100 Subject: [PATCH 2/4] added a method that allows for retrival of file by object id easily --- lib/Parse.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/Parse.js b/lib/Parse.js index 018448c..4449352 100644 --- a/lib/Parse.js +++ b/lib/Parse.js @@ -34,6 +34,13 @@ Parse.prototype = { parseRequest.call(this, 'POST', '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/1/users/', data, callback); }, + findWithObjectId: function (className, objectId, callback){ + var url = '/1/' + (className === '_User' ? 'users' : 'classes/' + className + '/' + objectId); + + + parseRequest.call(this, 'GET', url, null, callback); + + }, // get an object from the class store find: function (className, query, callback) { var url = '/1/' + (className === '_User' ? 'users' : 'classes/' + className); @@ -52,7 +59,7 @@ Parse.prototype = { // check to see if there is a 'where' object in the query object // the 'where' object need to be stringified by JSON.stringify(), not querystring if ( query.hasOwnProperty('where') ) { - url += '?where=' + encodeURIComponent(JSON.stringify(query.where)); + url += '?where=' + JSON.stringify(query.where); delete query.where; } @@ -95,6 +102,8 @@ Parse.prototype = { // user login loginUser: function (username, password, callback) { parseRequest.call(this, 'GET', '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/1/login/?username=' + username + '&password=' + password, null, callback); + + console.log(callback); }, // retrieve current user @@ -347,7 +356,13 @@ Parse.prototype = { sendPush: function (data, callback) { parseRequest.call(this, 'POST', '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/1/push/', data, callback); + }, + + getCurrentSession: function(objectId, callback) + { + parseRequest.call(this, 'GET', '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/1/sessions/'+ objectId, callback); } + }; // Parse.com https api request From 2f345845c2290069fccb206f7fef12b4ba267351 Mon Sep 17 00:00:00 2001 From: Victor Date: Mon, 27 Jul 2015 18:10:27 +0100 Subject: [PATCH 3/4] sorry i taken note of the uriencode --- lib/Parse.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Parse.js b/lib/Parse.js index 4449352..9f86e5a 100644 --- a/lib/Parse.js +++ b/lib/Parse.js @@ -59,7 +59,7 @@ Parse.prototype = { // check to see if there is a 'where' object in the query object // the 'where' object need to be stringified by JSON.stringify(), not querystring if ( query.hasOwnProperty('where') ) { - url += '?where=' + JSON.stringify(query.where); + url += '?where=' + encodeURIComponent(JSON.stringify(query.where)); delete query.where; } From d7dd68f423adff93be12789170db94c55bf4a29b Mon Sep 17 00:00:00 2001 From: Victor Date: Mon, 27 Jul 2015 18:16:11 +0100 Subject: [PATCH 4/4] left a nasty console.log there, I should have --- lib/Parse.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/Parse.js b/lib/Parse.js index 9f86e5a..f6dea3d 100644 --- a/lib/Parse.js +++ b/lib/Parse.js @@ -102,8 +102,6 @@ Parse.prototype = { // user login loginUser: function (username, password, callback) { parseRequest.call(this, 'GET', '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/1/login/?username=' + username + '&password=' + password, null, callback); - - console.log(callback); }, // retrieve current user