http-request-retry
Advanced tools
Comparing version 1.0.3 to 1.0.4
15
index.js
let _ = require('lodash'); | ||
let _request = require('request'); | ||
let queryString = require('query-string'); | ||
@@ -17,3 +18,3 @@ let HTTPService = { | ||
let requestCallback = (options = {}, done)=>{ | ||
done = done || function (){}; | ||
done = done || function (err, res){}; | ||
options.method = options.method || "POST"; | ||
@@ -24,2 +25,8 @@ options.json = true; | ||
options.headers = _.extend(options.headers || {}, { 'Content-Type': 'application/json; charset=UTF-8' }); | ||
if(options.method === 'GET' || options.method === 'get') | ||
{ | ||
if(options.url && options.url.indexOf('?') === -1 && _.isObject(options.body)){ | ||
options.url = options.url + '?' + queryString.stringify(options.body); | ||
} | ||
} | ||
_request(options, (error, response, body) => { | ||
@@ -48,2 +55,8 @@ let statusCode = (response && response.statusCode ) ? response.statusCode : 400; | ||
options.timeout = options.timeout || 60*1000; | ||
if(options.method === 'GET' || options.method === 'get') | ||
{ | ||
if(options.url && options.url.indexOf('?') === -1 && _.isObject(options.body)){ | ||
options.url = options.url + '?' + queryString.stringify(options.body); | ||
} | ||
} | ||
_request(options, (error, response, body) => { | ||
@@ -50,0 +63,0 @@ let statusCode = (response && response.statusCode ) ? response.statusCode : 400; |
{ | ||
"name": "http-request-retry", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "request can retry if fail", | ||
@@ -19,5 +19,6 @@ "repository": "https://github.com/xitrumuit1991/http-request-retry", | ||
"dependencies": { | ||
"lodash": "4.17.11", | ||
"request": "2.88.0" | ||
"lodash": "^4.17.11", | ||
"query-string": "^6.2.0", | ||
"request": "^2.88.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
25849
8
162
3
+ Addedquery-string@^6.2.0
+ Addeddecode-uri-component@0.2.2(transitive)
+ Addedfilter-obj@1.1.0(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addedquery-string@6.14.1(transitive)
+ Addedrequest@2.88.2(transitive)
+ Addedsplit-on-first@1.1.0(transitive)
+ Addedstrict-uri-encode@2.0.0(transitive)
+ Addedtough-cookie@2.5.0(transitive)
- Removedlodash@4.17.11(transitive)
- Removedpunycode@1.4.1(transitive)
- Removedrequest@2.88.0(transitive)
- Removedtough-cookie@2.4.3(transitive)
Updatedlodash@^4.17.11
Updatedrequest@^2.88.0