Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 08:58
    raRaRa opened #2677
  • 03:25
    linglingyun10 opened #2676
  • Jan 17 22:45
    rlee1990 opened #2675
  • Jan 17 21:26
    jonathanbardo commented #2646
  • Jan 17 16:38
    creatxrgithub commented #2672
  • Jan 17 16:30
    creatxrgithub commented #2672
  • Jan 17 14:26
    dumasss163 commented #1679
  • Jan 17 14:15
    HadiMohamadi commented #2326
  • Jan 17 13:43
    Keimeno review_request_removed #2647
  • Jan 17 13:29
    mr47 commented #2672
  • Jan 17 13:20
    Mohammed-Q96 commented #706
  • Jan 17 12:53
    dutgriff commented #853
  • Jan 17 09:01
    Larsrdev commented #2670
  • Jan 17 08:51
    Larsrdev commented #2670
  • Jan 17 08:25
    iyerusad commented #382
  • Jan 17 08:00
    iyerusad commented #382
  • Jan 17 07:58
    iyerusad commented #382
  • Jan 17 07:41
    dejour opened #2674
  • Jan 17 07:29
    rwam commented #2295
  • Jan 17 06:14
    ZeroCho commented #2671
Ghost
@ghost~5b50e037d73408ce4fa1903b
hey all - I have an interceptor for axios to catch expired API tokens for specific cases and return the original error response for all other cases.
The issue is that when it returns the errors for all other cases, it does not return the full error (which includes config, response, etc.), but a simplified version that has basic info (message, error name, etc.).
Any idea what I am doing wrong in my interceptor that is preventing it from returning the full error response?
my code: https://gist.github.com/cryocaustik/49c9e39bee2a16b3fa69e78716ae5105
Alex Skobelev
@cryocaustik
accidentally duplicated my account; the above post was me
lRoberth
@lRoberth

can anyone give me a hand?, i'm trying to post with axios, but nothing happens, here is my code
https://i.imgur.com/nWVAmi7.png
this is where i call the function
https://i.imgur.com/BwSCKRh.png

i'm in node.js

this is the console output
https://i.imgur.com/F6cLcqW.png

Watermelon Puppet
@xiGUAwanOU

Hello there, recently I have updated to v0.19.0, but found that the relative query path behaviour is not the same as it was in v0.18.1.

I'm working in a Vue.js project, and using the default TypeScript setup provided by vue-cli.

In Jest, I've set up the testURL as 'http://localhost/test/', and in the test, I'm trying to query with axios.get('api/healthcheck') for example. The log shows that I'm querying the path http://localhostapi/healthcheck, instead of http://localhost/test/api/healthcheck. However 0.18.1 has the expected behaviour.

I've checked the Jest version I'm using, they are the same, there is no changes at Jest side.

Can anyone confirm this behaviour change? Or did I do something wrong?
Jonathan Stevens
@jphilipstevens
Hello, I am a recently added maintainer for Axios. I am looking at the list of PRs to understand priority. So far I see that there was a regression that was fixed in #2207 Are there any other PR's that need immediate attention?
Domenico Corvasce
@domcorvasce
hey there. sorry to bother you this way, but anyone has any idea why axios does this? when the server is unreachable, it continues to send OPTION requests: alt
the code is correct, 'cause when the server is on all the requests are successful
i am on axios 0.19
Eyal Perry
@EyalPerry
Hi!
I'd like to make a small but important contribution, the axios.isTimeoutfunction.
I've made a PR, but some tests are failing, probably easy to fix for long term mantainers.
Can anyone take a look?
axios/axios#2495
rt1517
@rt1517
Hi, i need some help im new with axios, im getting timeout of 0ms exceededon XHR it is reported in rollbar notifying that error is generated by axios 0.18.0. i have no idea why it is happening. This issue is already created axios/axios#2103 .
  1. There is no timeout set , basically which means it is set to 0. (indefinite timeout)
  2. why it is giving an error timeout of 0ms exceeded?
  3. what can be done to handle this situation ?
    Thank you.
moritz bust
@busti
Great another js gitter channel with tons of questions and no answers.
moritz bust
@busti
Does anybody know if I can recover from an error inside of a response interceptor by making another request?
moritz bust
@busti
Looks like I can.
Florin Bunau
@fbunau
hi guys
anyone have any idea how to mock an axios response for a streaming endpoint ?
axios.get(stringUrl, {responseType: 'stream'}).then( ... )
.. I tried axios-mock-adapter , but it might have problems with this : ctimmerm/axios-mock-adapter#153
any other ideas ?
even manual mocking ?
I am fairly noob at node
I tried this :
const mystream = new Stream();

  mystream.pipe = function(dest) {
    dest.write(`
    {"name": "xxx", "id": 1}
    {"name": "yyy", "id": 2}
    `);
    return dest;
  };
and then this
mock.onGet(stringUrl, {responseType: 'stream'}).reply(200, mystream);
but seems it gives a
 UnhandledPromiseRejectionWarning: Unhandled promise rejection.
Florin Bunau
@fbunau
anyone else tried to mock a streaming endpoint ?
Florin Bunau
@fbunau
I might have answered my own question
fro other people that might stumble on this in the future
i solved it using nock
  nock(someStringUrl).get(somePath).reply(200, () => {
    return fs.createReadStream(path.join(__dirname, 'fixtures/data.json'))
  })
seems it is intercepting the calls at a very low level
Nejc Vukovic
@nvwebd

hey there: was wondering about the axios custom instance creation. I was wondering what I'm doing wrong -> I create an instance and export it -> then after some time I call an api to authenticate and after authentication I wan't to write the token to the axios instance with:

api.defaults.headers.common['Authorization' ] = '${user.token_type} ${user.access_token}';

But sadly after I call the API with a get request to get some data the "Authorization" is missing in the request.

Any ideas? Help?

Cheers!

Nejc Vukovic
@nvwebd

hey there: was wondering about the axios custom instance creation. I was wondering what I'm doing wrong -> I create an instance and export it -> then after some time I call an api to authenticate and after authentication I wan't to write the token to the axios instance with:

api.defaults.headers.common['Authorization' ] = '${user.token_type} ${user.access_token}';

But sadly after I call the API with a get request to get some data the "Authorization" is missing in the request.

Any ideas? Help?

Cheers!

used the interceptors :D

HanTengfeifei
@HanTengfeifei
HELLO
Jing Yi Wang
@namelesswc
Hello. I am creating a post request and I got confused to where to put in my request body. After reading the doc I can pass it in as data parameter: axios.post(url[, data[, config]]) but when I check out config it also has a parameter called data. So which is the one where I but my request body in.
George Kurobara Benjamin
@georgeben
Hello, please I am having an issue with ejecting an interceptor. Here's a link to the issue axios/axios#2615. After ejecting an interceptor from an axios instance, when I console.log() the axios instance, it is still thesame, i.e I still see the ejected interceptor as part of the request interceptors of the instance. Is it supposed to work this way? Thanks for any axplanation.
coldSeattle
@coldSeattle
hey everone
i have a problem with axios
can everyone help me&
?
i can not send a get to server
somefunction is not a function
Keisha Shepherd
@kshep425
@coldSeattle I have a problem too. Want to troubleshoot together?
The Tiến
@dthtien
hi guys. I have trouble with the intercepters hook. how can I make sure the refresh_token API in the code bellow call once if I have 2 or more API requests call at the same time?
thanks for supporting <3
httpClient.interceptors.response.use(
  response => response,
  error => {
    const isTokenRefreshing = 'isTokenRefreshing';
    const { response: { status, data: { key } }, config } = error;
    const isValidRefreshToken = !localStorage.getItem(isTokenRefreshing) && 
                                  status === UNAUTHORIZED_CODE &&
                                  key === REFRESH_KEY
    console.log("isTokenRefreshing", localStorage.getItem(isTokenRefreshing))
    console.log("status: ", status, " key: ", key)
    if (isValidRefreshToken) {
      localStorage.setItem(isTokenRefreshing, true);
      return  httpClient.post('fresh_token').then(() => {
        localStorage.removeItem(isTokenRefreshing)
        return httpClient(config);
      }).catch( error => {
        localStorage.removeItem(isTokenRefreshing)
        localStorage.removeItem('login');
        window.location.replace('/login');
        return Promise.resolve(error);
      });
    }

    // while(localStorage.getItem(isTokenRefreshing)) {
    //   console.log('refreshing')
    // }

    if(status === UNAUTHORIZED_CODE && key === REFRESH_KEY){
      localStorage.removeItem(isTokenRefreshing)
      return httpClient(config);
    }

    return Promise.reject(error);
  }
);
Dan Pastori
@danpastori
Hi Everyone, I have question with setting cookies with axios. I have my CORS set up server side to return an XSRF-COOKIE. I'm trying to send that cookie in the X-XSRF-TOKEN header that I append to each response. However, when I send it with axios it places it in the 'Cookie' header. I am using the basic default axios config with the same naming conventions in the documentation, but I can't figure out why it's sending in the cookie header and not the X-XSRF-TOKEN header. Any help would be greatly appreciated!
I get the set-cookie response properly from the server and it's only an http cookie.
I also make each request withCredentials: true
I can also provide any code samples necessary