question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Passing custom props via axios config

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:20
  • Comments:35

github_iconTop GitHub Comments

10reactions
lynnic26commented, Oct 11, 2019

need this too

10reactions
Christilutcommented, 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

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to add a custom property to axios config? - Stack Overflow
You can check the pull request Fixing custom config options. I have tried the latest version(0.21.1) of axios, the custom config works fine....
Read more >
Request Config | Axios Docs
Request Config. These are the available config options for making requests. Only the url is required. Requests will default to GET if method...
Read more >
Complete Guide to Axios HTTP Client - Reflectoring
An Axios instance created with Axios.create() with a custom config helps us to reuse the provided configuration for all the API invocations made ......
Read more >
How to make HTTP requests with Axios - LogRocket Blog
Making an HTTP request is as easy as passing a config object to the Axios function. You can make a POST request using...
Read more >
axios - npm
Start using axios in your project by running `npm i axios`. ... axios API. Requests can be made by passing the relevant config...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found