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

Arrow function, this and promise #920

Closed
darakt opened this issue May 27, 2017 · 1 comment
Closed

Arrow function, this and promise #920

darakt opened this issue May 27, 2017 · 1 comment

Comments

@darakt
Copy link

darakt commented May 27, 2017

Hi, I change recently to Axios and I can't figure why the this isn't "working" properly inside the promise.
`let all = {
method: 'POST',
url: 'https://XXXXXX',
data: data,
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
}
};

    axios(all)
        .then((response) => {
            this.setState({
                ...this.state,
                spin: false,
            });
            self.props.router.push('panel');
        })
        .catch((error) => {
            this.setState({
                spin: false,
                errorLogin: 'Username or password wrong',
            });
        });`

In the end my this.setState is not a function which the use of an arrow function should avoid...

@rubennorte
Copy link
Member

From the code you share I can't really help, as I don't see anything wrong. I'm closing as this isn't an issue in Axios anyway.

@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

2 participants