added axios-retry support

This commit is contained in:
srgooglo 2022-09-09 13:31:06 +02:00
parent 3e441ded1c
commit b8926dfdab
2 changed files with 11 additions and 2 deletions

View File

@ -21,6 +21,7 @@
"@corenode/utils": "0.28.26",
"@nanoexpress/middleware-body-parser": "^1.2.2",
"axios": "0.27.2",
"axios-retry": "^3.3.1",
"cors": "2.8.5",
"express": "^4.18.1",
"hyper-express": "^6.1.1",

View File

@ -1,4 +1,5 @@
const axios = require("axios")
const axiosRetry = require("axios-retry")
const camalize = require("@corenode/utils/dist/camalize").default
const { WSInterface } = require("./classes")
@ -46,13 +47,20 @@ module.exports = class Bridge {
}
})
if (this.params.enableRetry) {
axiosRetry(this.httpInterface, {
retries: this.params.onFailRetries ?? 1,
retryDelay: this.params.retryDelay ?? 0,
})
}
return this
}
initialize = async () => {
const instanceManifest = await this.httpInterface.get("/")
.then(res => res.data)
.catch(err => {
.then((res) => res.data)
.catch((err) => {
console.error(err)
throw new Error(`Could not get endpoints map from server. [${err.message}]`)
})