- // Add signature if it is specified in the params
- if (params.sign === true) {
- const host = CONFIG.WEBSERVER.HOST
+type MakeRetryRequestParams = {
+ url: string,
+ method: 'GET' | 'POST',
+ json: Object
+}
+function makeRetryRequest (params: MakeRetryRequestParams) {
+ return new Promise<{ response: request.RequestResponse, body: any }>((res, rej) => {
+ replay(
+ request(params, (err, response, body) => err ? rej(err) : res({ response, body })),
+ {
+ retries: RETRY_REQUESTS,
+ factor: 3,
+ maxTimeout: Infinity,
+ errorCodes: [ 'EADDRINFO', 'ETIMEDOUT', 'ECONNRESET', 'ESOCKETTIMEDOUT', 'ENOTFOUND', 'ECONNREFUSED' ]
+ }
+ )
+ })
+}