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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

axios delete request with body #18

Open
l-ll opened this issue May 22, 2019 · 2 comments
Open

axios delete request with body #18

l-ll opened this issue May 22, 2019 · 2 comments

Comments

@l-ll
Copy link
Owner

l-ll commented May 22, 2019

馃敆

axiox.delete does support a request body. It accepts two parameters: url and optional config. You can use config.data to set the response body as follows:

axios.delete(url, { data: { foo: "bar" } });

post, put, and patch accept 3 parameters: url, data, and config so you can you can use the second parameter to set the response body like this:

axios.put(url, { foo: "bar" });

Hope it helps!

@l-ll
Copy link
Owner Author

l-ll commented Jul 3, 2019

axios.interceptors.response.use(null, (error) => {
  if (error.config && error.response && error.response.status === 401) {
    return updateToken().then((token) => {
      error.config.headers.xxxx <= set the token
      return axios.request(config);
    });
  }

  return Promise.reject(error);
});

Is it possible to add a retry method to axios?

@titusdecali
Copy link

This trips me up every single time I do a new project. Seriously wish Axios would just stay consistent with the config across all methods.

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

2 participants