Giter VIP home page Giter VIP logo

Comments (5)

angelhdzmultimedia avatar angelhdzmultimedia commented on June 14, 2024

Update

I made a new project, on stackblitz.com, to store, increase, and reset a count number.
It shockingly works great there!!!

https://stackblitz.com/edit/node-ycluk6

The only difference is, in this project, I'm checking if the req.session.count is undefined and I assign a default value.
Oh and Node versions. But I tried on my local project with versions 18.1.0 and 16.18.0 and same issue.

from session.

angelhdzmultimedia avatar angelhdzmultimedia commented on June 14, 2024

Update 2

Beliving that I could only store primitives in the session, instead of storing the whole User object, I stored it's id, to later find the user with the id from the users array.

The id from the session comes undefined!!!

from session.

angelhdzmultimedia avatar angelhdzmultimedia commented on June 14, 2024

Solved

The counter example worked because I made the requests in the browser, so the session could be stored in cookies.
The other examples, I made the requests via Rapid API Client extension in VSCode (and apparently it doesn't store cookies, new to me). Another test I made, was using another script, that used the node-fetch api, to make the login/register/user requests to the express server, and apparently, that doesn't store cookies as well.

So after I decided to make an user interface in the browser, to test this deeper and to be able to make the request pressing buttons, it worked right away! And then I checked the Application > Cookies and the session was there,
and the user is being returned.

I hope this experience is helpful to someone in the future (or to my forgetful future self wink).

Note: I normally test everything with an user interface in the browser, but this time I'm recording tutorials to teach a relative about NodeJS, TypeScript and soon Vue 3 and Nuxt 3, so that made me go back to the "root", vanilla everything :P

from session.

angelhdzmultimedia avatar angelhdzmultimedia commented on June 14, 2024

Update

I managed to get it working in VSCode > Rapid API Client extension.
I just had to pass the Cookie to the /auth/user GET request. Wondering why in the browser it happens automatically...
even though in Rapid API Client extension I have the options:
image

Anyway, looking great!

image

from session.

angelhdzmultimedia avatar angelhdzmultimedia commented on June 14, 2024

Last Update (I promise!)

The issue was with Rapid API Client VSCode extension.

I switched to Thunder Client extension, and I didn't have to set cookies manually! Phew!!! 😂🙄😔🤡

image

from session.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.