-
-
Notifications
You must be signed in to change notification settings - Fork 249
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
Location of 'await' in examples/next.js/pages/login.jsx #329
Comments
@davebm1 I think you're right but I never got really down to the root cause/which way we should do mutate/fetch. Can you investigate the root cause and what's the best way to do "mutate local + fetch"? We're using https://github.com/vercel/swr It's true that on my own app code I tend to do mutate and then await fetch instead of await end then fetch. Then we can safely update the example code here and in the Next.js repo (https://github.com/vercel/next.js/blob/canary/examples/with-iron-session/pages/login.js) |
The promise is returned from fetch, not from swr, so mutate..await..fetch seems the better option. This approach seems to be supported on the swr npm page https://www.npmjs.com/package/swr Section: Mutate Based on Current Data:-
and
The next-iron-session example also uses await this way for logout in
I was getting intermittent authentications problems with await..mutate..fetch with failure to redirect Regards... |
Thanks, just updated the examples 🙏 |
…example link (#25889) This updates the with-iron-session example with: - updated way to mutate + fetch (re: vvo/iron-session#329) - updated readme to include TypeScript example link Requirements: - [x] Make sure the linting passes
…example link (vercel#25889) This updates the with-iron-session example with: - updated way to mutate + fetch (re: vvo/iron-session#329) - updated readme to include TypeScript example link Requirements: - [x] Make sure the linting passes
Should lines 24/25 of examples/next.js/pages/login.jsx read :-
...
24 mutateUser(
25 await fetchJson("/api/login", {
...
and not :-
...
24 await mutateUser(
25 fetchJson("/api/login", {
...
I was getting intermittent login problems on a slower connection. Making the above change resolved this.
Thanks...
The text was updated successfully, but these errors were encountered: