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

[Unhandled promise rejection: Error: Request failed with status code 401] #26

Open
j-terranova opened this issue Oct 18, 2022 · 2 comments

Comments

@j-terranova
Copy link

j-terranova commented Oct 18, 2022

I was able to setup and install both the easy-shop and the backend. I was able to register but whenever the get is fired off (after register and login), I get the error:
[Unhandled promise rejection: Error: Request failed with status code 401]

It looks like it is happening on the return from the login. After I login the user id that is passed to the get is undefined.

Are there updates to the code to fix this?

Also, I can see my console logs on the back end but I do not see any console logs on the front end. Can you tell me where these logs are written so that I can look at them?

@FilipSantic
Copy link

That doesn't cause this. There is a minor bug in easy-shop/Screens/User/UserProfile.js
From lines 28 to 55, everything should be wrapped in an "else" case which is connected to the "if" on line 22.
The reason is that we only want these actions if the user is authenticated. If not, we will just navigate him to the login page.
Also, on line 32, I switched context.stateUser.user.sub to context.stateUser.user.id, and now I don't receive undefined, but rather a proper id from params.

@jeseekm
Copy link

jeseekm commented Dec 2, 2022

That doesn't cause this. There is a minor bug in easy-shop/Screens/User/UserProfile.js From lines 28 to 55, everything should be wrapped in an "else" case which is connected to the "if" on line 22. The reason is that we only want these actions if the user is authenticated. If not, we will just navigate him to the login page. Also, on line 32, I switched context.stateUser.user.sub to context.stateUser.user.id, and now I don't receive undefined, but rather a proper id from params.

To add to this... on checkout.js line 30 should change to setUser(context.stateUser.user.userId) for the user specific items to render on the UI.

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

3 participants