Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

it's not working with axios v.19.0 #62

Closed
xnog opened this issue Jul 9, 2019 · 18 comments
Closed

it's not working with axios v.19.0 #62

xnog opened this issue Jul 9, 2019 · 18 comments
Labels
enhancement New feature or request needs info I need more information!

Comments

@xnog
Copy link

xnog commented Jul 9, 2019

it's not working with axios v.19.0

@JustinBeckwith JustinBeckwith added the enhancement New feature or request label Jul 9, 2019
@dennisreimann
Copy link

Yes, the reason for that is – as @adntin points out here – that Axios 0.19 filters out custom properties.

@JustinBeckwith
Copy link
Owner

Yeah - sadly I doubt I'm going to be updating this library to support the latest version 😢 We just don't use this at my company anymore, so I don't have a ton of time to keep it up to date. If others are interested ... I'd happily accept PRs!

@dennisreimann
Copy link

fyi: We just fixed this by using the same meachanism, but using a custom header field instead of the custom config property.

@avindra
Copy link

avindra commented Aug 12, 2019

This is kind of janky but you can patch axios 0.19 directly in node_modules to permit raxConfig as a valid key.

Patch:

diff --git a/node_modules/axios/lib/core/mergeConfig.js b/node_modules/axios/lib/core/mergeConfig.js
index 6097a3e..1ec151e 100644
--- a/node_modules/axios/lib/core/mergeConfig.js
+++ b/node_modules/axios/lib/core/mergeConfig.js
@@ -38,7 +38,7 @@ module.exports = function mergeConfig(config1, config2) {
     'timeout', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
     'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'maxContentLength',
     'validateStatus', 'maxRedirects', 'httpAgent', 'httpsAgent', 'cancelToken',
-    'socketPath'
+    'socketPath', 'raxConfig'
   ], function defaultToConfig2(prop) {
     if (typeof config2[prop] !== 'undefined') {
       config[prop] = config2[prop];

then in your package.json:

    "postintall": "patch -p1 -N < /axios-config-fix.patch",

@ghost
Copy link

ghost commented Aug 27, 2019

@dennisreimann Hi please can you demonstrate how you managed to fix this?

@dennisreimann
Copy link

@KayHS see this comment.

Whereas before you have assigned the property directly to the config (i.e. config.retryCount) you now need to use a custom header for that (i.e. headers.common['retryCount']).

@ghost
Copy link

ghost commented Aug 27, 2019

@dennisreimann

hnn, my setup is like the following

import { attach, getConfig } from "retry-axios";
import axios from "axios";

 const interceptorId = attach();

  const options: any = {
            method: "get",
            url,
            headers: {
                "X-ID": classificationRequest.id,
            },
            data: {},
            raxConfig: retryConfig,
        };

so headers.common['raxConfig'] = retryConfig?

@dennisreimann
Copy link

Or something like this:

headers: {
  "X-ID": classificationRequest.id,
  "x-retry-count": 0
},

It does not really matter, as long as you write to the same header property you also read from.

@findmory
Copy link
Contributor

or you can use the master version on git npm install axios/axios#master . I've confirmed that they fixed the issue with custom params there just haven't pushed it to npm

@fabrusso
Copy link

fabrusso commented Jan 3, 2020

or you can use the master version on git npm install axios/axios#master . I've confirmed that they fixed the issue with custom params there just haven't pushed it to npm

Tried it and It's working, also with other NPM libraries for retries.

Thanks a lot.

@DanielRuf
Copy link

You can apply the patch using patch-package.

@JustinBeckwith
Copy link
Owner

@DanielRuf it looks like 0.19.1 went out, and should include the fix. I am a little confused because my tests currently use 0.19.1, and everything appears to be passing. Could I trouble someone for a simple repro that shows this?

@JustinBeckwith JustinBeckwith added the needs info I need more information! label Jan 15, 2020
@DanielRuf
Copy link

In our project it didn't work with the custom options. Headers might work but I chose the normal solution from the docs.

@DanielRuf
Copy link

@DanielRuf
Copy link

I will check that again. But we pinned the version.

@DanielRuf
Copy link

axios/axios@a11cdf4

@DanielRuf
Copy link

Seems to be fixed in 0.19.1 but we'll still apply the patch to ensure that it will work.

@JustinBeckwith
Copy link
Owner

Awesome. Seems like it's working, so I'm closing this out :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs info I need more information!
Projects
None yet
Development

No branches or pull requests

7 participants