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

Basic auth with form data (react/redux) #527

Closed
jabacchetta opened this issue Nov 7, 2016 · 3 comments
Closed

Basic auth with form data (react/redux) #527

jabacchetta opened this issue Nov 7, 2016 · 3 comments

Comments

@jabacchetta
Copy link

jabacchetta commented Nov 7, 2016

I'm trying to replicate a working auth request with axios (currently implemented using reqwest). I've read through #167 and #97 and have gotten close, but still not quite there.

Here's a working example using reqwest.

reqwest

I tried duplicating the request exactly (according to the network tab) using axios, and this is what I came up with (using a suggested transform workaround from one of the threads above):

transform

From the network tab, this solution appears to have worked for the request being manipulated, but the next Redux action (loadCurrentUser) that gets dispatched from that .then success fails, giving me the following error (which I did not get with the original reqwest solution):

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. The response had HTTP status code 401.

I also tried using params in the config and received the exact same error.

What am I doing wrong here?

@nickuraltsev
Copy link
Member

It doesn't look like you need to use that transform workaround. There are easier ways to convert a JavaScript object to the application/x-www-form-urlencoded format. Please see this comment.

@nickuraltsev
Copy link
Member

Closing due to inactivity. Please feel free to reopen.

@jabacchetta
Copy link
Author

Great, the qs library worked, thanks!

@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