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

Passing custom props via axios config #2295

Closed
Alex-Sokolov opened this issue Jul 18, 2019 · 35 comments
Closed

Passing custom props via axios config #2295

Alex-Sokolov opened this issue Jul 18, 2019 · 35 comments

Comments

@Alex-Sokolov
Copy link

Describe the bug
We use some custom parameters via axios configuration. They are used in the response interceptor. Sometimes there may be a lot of information there, so the option to pass it through the headers or params is not suitable for us because of the length limit

To Reproduce

  • Open: https://jsfiddle.net/w2rmhy4c/1/
  • Attach axios 0.18 (uncomment line with axios@0.18.0)
  • Run fiddle (console show true)
  • Attach axios 0.19 (uncomment line with axios@0.19.0)
  • Run fiddle (console show undefined)

Expected behavior
Custom config parameter passed. Or the ability to use another config option to pass custom data.

Environment:

  • Axios Version 0.18/0.19

Additional context/Screenshots
First messages with axios 0.18, second with 0.19

@Alex-Sokolov Alex-Sokolov changed the title Pass custom props in config Passing custom props via axios config Jul 18, 2019
@idseventeen
Copy link

I have the same problem

@Christilut
Copy link

Christilut commented Jul 25, 2019

I need this too. I had this working in 0.18 but it stopped working in 0.19

I used something like this:

    await axios({
      url: '/search',
      method: 'GET',
      params,
      myCustomParameter: true
    } as ICustomAxiosRequestConfig)

but it no longer shows up in the interceptor config:

axios.interceptors.request.use(function (config) {
})

Edit: just confirmed this works in 0.18.1 so I'm reverting back for now

@ggedde
Copy link

ggedde commented Jul 25, 2019

Same Here. Reverting back to 18.1 works.

@eric7578
Copy link

Revert to 18.1 as well

@SevenGuns
Copy link

Me too. But why 0.19.0 can't do?

@TvojTatk0
Copy link

Same here. I'm not able to use custom param in AxiosRequestConfig in 0.19.0 anymore. It would be awesome if there was possibility to use some custom id per request. I'm using response interceptor for global error handling but in a few requests (2-3 of 50) I need different behavior.

@yosimasu
Copy link

yosimasu commented Aug 6, 2019

I found 0.19 introduce mergeConfig to filter out config.

https://github.com/axios/axios/blob/master/lib/core/mergeConfig.js#L18-L42

@webliving
Copy link

so, What should I do, i need config resetful API

@jmike
Copy link

jmike commented Aug 12, 2019

Either revert back to v.18 or wait for a fix.

@webliving
Copy link

When to Consider Re-support ? 😃

@lynnic26
Copy link

lynnic26 commented Oct 11, 2019

need this too

@Ragash
Copy link

Ragash commented Oct 12, 2019

BLOODY +1

i lost 4h of work until found this issue

@Flyrell
Copy link

Flyrell commented Oct 12, 2019

This is why I was thinking about something like #1890 ... hope we cen resolve it fast.

@imshenshen
Copy link

I revert back to axios@0.18.0, and there is no BREAKING CHANGE described in 0.19.0 ??!!😱️

@Askadias
Copy link

+1

@liamwang
Copy link

Need this too. Revert to 0.18.0 as well.

@viulu5824
Copy link

I think axios should consider opening the interface to custom configuration parameters or backing out the version

@yasuf
Copy link
Collaborator

yasuf commented Nov 4, 2019

This change is already in master, it's a matter of releasing a new version, possibly this upcoming week, cc @emilyemorehouse, this is the PR: https://github.com/axios/axios/pull/2207/files

@yasuf
Copy link
Collaborator

yasuf commented Nov 4, 2019

sorry guys for the inconvenience, hopefully we can have a new version released soon, in the meantime using 0.18 is the best alternative

@johnculviner
Copy link

No need to filter out stuff like this in Javascript. Being able to do stuff like this is one of the amazing parts of the language!

@artursudnik
Copy link

+1

1 similar comment
@isimonov
Copy link

+1

@Flyrell
Copy link

Flyrell commented Nov 13, 2019

I'm still think that we should create something similar to what I described in #1890 in the future releases. It has some advantages I can think of right now:

  1. it gives us a standard way to deal with custom data in the request objects (this helps us when working with e.g. interceptors, which is a strong point when choosing axios over other http libraries)
  2. we could add to the documentation as many people don't know (or are scared) that request object is untouched (well at least it was until now).
  3. when contributing we would possibly prevent issues like this one from happening again

I'm not saying that the object/property name should be userData as described in the issue, but it surely is worth a discussion.

@cristianocca
Copy link

Any updates on on this? Still stuck with 0.18.1 due to this. I get the love for typescript, but please revert this to the previous behavior :(

@elonmir
Copy link

elonmir commented Nov 19, 2019

Yeah, I just ran into the same issue for my vue app. I just wanted to mock some delay function for the requests, to test the app's stability. An update or workaround for this would be nice.

@AndyOGo
Copy link

AndyOGo commented Dec 5, 2019

Great lib, but same for me. I need custom properties

@neizmirasego
Copy link

+1

1 similar comment
@Garwin4j
Copy link

Garwin4j commented Dec 5, 2019

+1

@mbaev
Copy link

mbaev commented Dec 8, 2019

Yeah, custom properties will be very helpful. Thank you, guys for this awesome tool!

@astronati
Copy link

+1

1 similar comment
@ricardoboss
Copy link

+1

@chinesedfan
Copy link
Collaborator

Fixed in #2207.

@Levayv
Copy link

Levayv commented Jan 16, 2020

Same, param is missing, 18.1 is a solution (for now). Thanks @Alex-Sokolov.

@rwam
Copy link

rwam commented Jan 17, 2020

Same, param is missing, 18.1 is a solution (for now). Thanks @Alex-Sokolov.

But 0.19.1 should solves this. We've updated and tested this successfully, so there is no need for a downgrade anymore.

@axios axios locked and limited conversation to collaborators May 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests