reddit-wrapper-v2
Advanced tools
Comparing version 1.0.10 to 1.0.12
17
api.js
@@ -30,2 +30,3 @@ const request = require('request'); | ||
// DISABLED FOR NOW. CAUSING ERRORS WHEN USED WITH RETRY ON WAIT. | ||
// Retry on reddit server error | ||
@@ -35,3 +36,3 @@ // If this parameter is present, then the server will retry on a reddit server error. You can also specify the retry wait duration. | ||
this.retry_delay = 5; // Default 5sec retry delay | ||
if (options.retry_on_server_error) { | ||
/*if (options.retry_on_server_error) { | ||
this.retry_on_server_error = options.retry_on_server_error; | ||
@@ -41,3 +42,3 @@ if (options.retry_delay) { | ||
} | ||
} | ||
}*/ | ||
@@ -65,3 +66,2 @@ // If logs are enabled, default to true. | ||
return new Promise(function(resolve, reject) { | ||
self.logHelper("Obtaining new reddit token."); | ||
request.post({ | ||
@@ -133,4 +133,3 @@ url: ACCESS_TOKEN_URL, | ||
if (body && body.json && body.json.ratelimit) { | ||
self.logHelper("You have tried this too much error has occured."); | ||
return reject(new Error("you are doing this too much, try again in: " + body.json.ratelimit + " seconds")); | ||
return reject("you are doing this too much, try again in: " + body.json.ratelimit + " seconds"); | ||
} else { | ||
@@ -154,3 +153,4 @@ return resolve([res.statusCode, body]); | ||
let self = this; | ||
if (self.retry_on_server_error > 0) { | ||
return self._make_request(token, endpoint, method, data); | ||
/*if (self.retry_on_server_error > 0) { | ||
return new Promise(function(super_resolve, super_reject) { | ||
@@ -172,2 +172,4 @@ return Promise.mapSeries(new Array(self.retry_on_server_error + 1), function() { | ||
} | ||
// Getting stuck right here when 'retry_on_wait' & 'retry_on_server_error' are enabled at the same time. | ||
}); | ||
@@ -184,4 +186,3 @@ }); | ||
} else { | ||
return self._make_request(token, endpoint, method, data); | ||
} | ||
}*/ | ||
} | ||
@@ -188,0 +189,0 @@ |
{ | ||
"name": "reddit-wrapper-v2", | ||
"version": "1.0.10", | ||
"version": "1.0.12", | ||
"description": "Simple Reddit API framework for nodejs. Replacing the no longer updated reddit-snooper. Relying more on promises rather than callbacks.", | ||
@@ -5,0 +5,0 @@ "main": "reddit-wrapper.js", |
@@ -54,10 +54,2 @@ | ||
retry_on_wait: true, // Default: false | ||
// Retry on Server Error tells the wrapper to retry making requests a certain amount | ||
// of times, if a reddit server error is encountered (Ie. "Ow. Please try again."). | ||
// Specifying 5 times will attempt the request a MAXIMUM of 6 times. | ||
retry_on_server_error: 5, // Default: 0 | ||
// Retry Delay specifies the delay between server error retries. The unit is seconds. | ||
retry_delay: 1, // Default: 5 seconds. | ||
}) | ||
@@ -64,0 +56,0 @@ ``` |
@@ -170,3 +170,3 @@ var assert = require('assert'); | ||
describe("Server Error, retry max 5 times. Sixth and final retry is success. No delay.", function() { | ||
/*describe("Server Error, retry max 5 times. Sixth and final retry is success. No delay.", function() { | ||
beforeEach(() => { | ||
@@ -298,2 +298,2 @@ var rOptions = secrets.redditOptions; | ||
}); | ||
}); | ||
});*/ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21446
158