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

third parameter of interceptors.request.use not work #3736

Closed
afishhhhh opened this issue Apr 7, 2021 · 13 comments
Closed

third parameter of interceptors.request.use not work #3736

afishhhhh opened this issue Apr 7, 2021 · 13 comments

Comments

@afishhhhh
Copy link

Describe the bug

onFulfilled of axios.interceptors.request.use run always.

To Reproduce

axios.interceptors.request.use(
  config => {
    console.log(config)
    debugger
    return config
  },
  null,
  {
    synchronous: true,
    runWhen: config => {
      console.log('runWhen')
      debugger
      return config.method === 'get'
    }
  }
)

Expected behavior

onFulfilled run only if method == 'get'

Environment

  • Axios Version 0.21.1
  • Adapter [e.g. XHR/HTTP]
  • Browser Chrome
  • Browser Version [e.g. 22]
  • Node.js Version [e.g. 13.0.1]
  • OS: [e.g. iOS 12.1.0, OSX 10.13.4]
  • Additional Library Versions [e.g. React 16.7, React Native 0.58.0]

Additional context/Screenshots

Add any other context about the problem here. If applicable, add screenshots to help explain.

@JohnMarsden24
Copy link

Same issue, interceptor always runs so having to put in checks in the function body.

@chinesedfan
Copy link
Collaborator

Note that this feature is just on the master branch, but not released yet.

@EmreErdogan
Copy link

Note that this feature is just on the master branch, but not released yet.

@chinesedfan Do you know when this will be released or is there an estimation you're aware of?

@gfoidl
Copy link
Contributor

gfoidl commented Apr 28, 2021

on the master branch, but not released yet.

Can there be a hint in the ReadMe, as it shows the usage of these parameter?
At the moment it's a bit confusing (that's why I landed here).

@Mottoweb
Copy link

Has this been released yet?

@sergejostir
Copy link

No.

@ant-plotnikov
Copy link

ant-plotnikov commented Aug 13, 2021

@anglinb hello, any plans to publish this to npm?

@amir-beheshty
Copy link

If the feature is not yet available on a stable release then why is it in Readme w/o a note?
I think either the ReadMe should be updated or the feature should be made available.

@eshaan7
Copy link

eshaan7 commented Sep 7, 2021

This issue persists in version 0.21.4 as well.

@chinesedfan
Copy link
Collaborator

This feature should have been release in 0.21.2, but TS definition isn't updated yet(see #3842). @eshaan7 if you still can't use it totally, feel free to remind me.

@shum-dev
Copy link

shum-dev commented Feb 11, 2022

ver 0.25.0 still doesn't work in TS

@thepuzzlemaster
Copy link

Looks like this was fixed here: #3800 (March 7, 2022). But it doesn't look like it's made it into an officially published version yet.

@thepuzzlemaster
Copy link

thepuzzlemaster commented Apr 12, 2022

Although, I'm very confused by this. Because according to this diff, it went in between 0.26.0 and 0.26.1, but when I install 0.26.1, it's still not available in index.d.ts.

Yes. Here is the file in the 0.26.1 tag. Is it possible something else got published to npm, which doesn't include this typedef in index.d.ts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests