{"_id":"@argueta10/http-request-retry","name":"@argueta10/http-request-retry","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@argueta10/http-request-retry","version":"1.0.0","description":"Request retry es la interfaz de axios implementando 3 nuevos parametros.","main":"index.js","types":"index.d.ts","scripts":{"test":"npm run build && mocha -r ts-node/register --exit test/*.spec.ts","build":"tsc"},"author":{"name":"Gerardo Argueta","email":"arguetagra15@gmail.com","url":"https://github.com/argueta15"},"repository":{"type":"git","url":"git+https://github.com/argueta15/http-request-retry.git"},"license":"ISC","devDependencies":{"@types/mocha":"^9.1.1","@types/sinon":"^10.0.13","assert":"^2.0.0","mocha":"^10.0.0","mocha-sonar-generic-test-coverage":"^0.0.1","nock":"^13.2.9","nyc":"^15.1.0","sinon":"^14.0.0","ts-node":"^10.9.1","tslint":"^6.1.3","typescript":"^4.7.4"},"dependencies":{"@types/ioredis":"^4.28.10","@types/memory-cache":"^0.2.2","@types/request-promise":"^4.1.48","axios":"^0.27.2","http-status":"^1.5.2","ioredis":"^5.2.1","js-sha256":"^0.9.0","memory-cache":"^0.2.0","retry-axios":"^3.0.0"},"gitHead":"3d55207d9c7d210030d6f02ab575034e737f594b","bugs":{"url":"https://github.com/argueta15/http-request-retry/issues"},"homepage":"https://github.com/argueta15/http-request-retry#readme","_id":"@argueta10/http-request-retry@1.0.0","_nodeVersion":"14.17.6","_npmVersion":"8.17.0","dist":{"integrity":"sha512-27apa/ZFXqPFsS8vopw2PL2gfiq0NQd3GErHojiv6DOzPd6jkpAJtQ0EHRvVjjgzxqhixUh2l0AvFeXeRLbdCA==","shasum":"8d1f47a594f20124bd4877d31c47c158eadb5d33","tarball":"https://registry.npmjs.org/@argueta10/http-request-retry/-/http-request-retry-1.0.0.tgz","fileCount":8,"unpackedSize":19316,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCTJQCeZeVCBv6tlGt2r6rex8WdTfTa6uG5CEnW9ply/wIgKXuLRVOM13fgjXiga4CWN6jJ9G6IhGDh+Qwhh1DEe90="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi9Ae9ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoyNA/8CroAvtzpSTwhQBiMlcQVCVVESO1odaQTAPvpuDcUqN/3odAb\r\nTiODq4JLYJaR9IJMIrswgH0zxj/aHT2Jd7+BeoftZZCpXi1kfeInN1LH5ogx\r\n8k22UXNA+brLAdeOokUDl4h8o3dFZzizpmDGNEYidWa85SBXfLBEeRHTQPod\r\nWCs6zv+IOlUACwYqFYJvw7oahKD7Nk7Ri7vHpyPC4EpYUDA7AW0oekD+rMOS\r\ntnLw0zAL4+Eo7RYla9ww8oJi/dQhj9kSDq3/rLf2j1Y/YVLTKMis8ISpVKOS\r\nBlpvSuwQJySLNVF0bElHfdbvP4+Ueu5Iulm2KV6vps5mMf+depZvF+1fhfBa\r\npBl/rWBMAga9q2hlcmQo/kmg+JW9GbKuAcQuZaQp22yugnM8YSxpCpJB09tH\r\nI+eJF7g3AzJPc8zBHyik4GtB8xQFZsEUAjS6gHsqURfGJsBCNguxKn/x5V1q\r\nl/xtVvS6XisXQ+kLz7SRkiUYvK7aJF5A6bTGyosilNiGXKu++TXaBQRe9Y/1\r\nIQwrIepzTJV51xEK5aquYNQSlWIVRnJjU+i5xTnSIcMpJ4uChlGMg+bvaV9r\r\nS8nTtLzV3deZTv50BsGqPh5K0zFVqTiW6O9Q68o6eJlEHE8M2iNkZfc7cNnw\r\nF5/2nGS2zaZYO0v3+alUqZpwqihYM8P+hpA=\r\n=F7BJ\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"argueta10","email":"arguetagra15@gmail.com"},"directories":{},"maintainers":[{"name":"argueta10","email":"arguetagra15@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/http-request-retry_1.0.0_1660159933715_0.8024732757730264"},"_hasShrinkwrap":false}},"time":{"created":"2022-08-10T19:32:13.655Z","1.0.0":"2022-08-10T19:32:13.916Z","modified":"2022-08-10T19:32:14.066Z"},"maintainers":[{"name":"argueta10","email":"arguetagra15@gmail.com"}],"description":"Request retry es la interfaz de axios implementando 3 nuevos parametros.","homepage":"https://github.com/argueta15/http-request-retry#readme","repository":{"type":"git","url":"git+https://github.com/argueta15/http-request-retry.git"},"author":{"name":"Gerardo Argueta","email":"arguetagra15@gmail.com","url":"https://github.com/argueta15"},"bugs":{"url":"https://github.com/argueta15/http-request-retry/issues"},"license":"ISC","readme":"# Request Retry\n\nRequest retry is the axios interface implementing 3 new parameters [fallbackResponse, cache, maxRetry].\n\n\n- ### fallbackResponse\n\nIn case the request fails, it returns the object stored in the fallbackResponse parameter:\n```js\nimport * as rp from 'request-retry';\n\nconst options = {\n  url: `${Env.get('API_URL')}`,\n  headers: { 'Content-Type': 'application/json' },\n  fallbackResponse: []\n}\n\nreturn rp.get(options) //in case it fails the object is returned []\n```\n\nOr also, if the request fails, execute a function that will receive the error and the options used to make the request as the only parameter.\n```js\nimport * as rp from 'request-retry';\n\nconst options = {\n  url: `${Env.get('API_URL')}`,\n  headers: { 'Content-Type': 'application/json' },\n  fallbackResponse: (e, data) => e.response.status === 400 ? [] : ['fake'],\n}\n\nreturn rp.get(options) //in case it fails, the function passed by parameter will be executed\n```\n\n- ### cache\n\nCache the service response in case the http code is 200:\n```sh\nimport * as rp from 'request-retry';\n\nconst options = {\n  url: `${Env.get('API_URL')}`,\n  headers: { 'Content-Type': 'application/json' },\n  cache: 1\n}\n\nreturn rp.get(options) \n```\n- ### maxRetry\n\nIf the error code is 504 or 503, the request is retried the configured number of times:\n```sh\nimport * as rp from 'request-retry';\n\nconst options = {\n  url: `${Env.get('API_URL')}`,\n  headers: { 'Content-Type': 'application/json' },\n  maxRetry: 3\n}\n\nreturn rp.get(options) \n```","readmeFilename":"README.md"}