question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Wrong argument in req.session.data in Getting started part 7

See original GitHub issue

Description of the issue

There is an error in part 7 of the Getting started tutorial, which does not allow the form to go as intended. If we give an answer other than “3 or more” we should be redirected to “ineligible.html” page. What does happen at the moment is that no matter what answer we choose, we will always be redirected to “ineligible.html”.

Steps to reproduce the issue

Doing the tutorial as intended, in part 7 we stumble across this code:

`router.post(‘/juggling-balls-answer’, function (req, res) { // Make a variable and give it the value from ‘juggling-balls’ var jugglingBalls = req.session.data[‘juggling-balls’]

// Check whether the variable matches a condition if (jugglingBalls == “3 or more”){ // Send user to next page res.redirect(‘/juggling-trick’) } else { // Send user to ineligible page res.redirect(‘/ineligible’) }

})`

Where in part 4 we are asked to set the name and idPrefix of the form in “juggling-balls.html” to “how-many-balls”, like this:

{{ govukRadios({ idPrefix: “how-many-balls”, name: “how-many-balls”, fieldset: { legend: { text: “How many balls can you juggle?”, isPageHeading: true, classes: “govuk-fieldset__legend–l” }

Actual vs expected behaviour

We expect the program to redirect us to ‘ineligible.html’ when we choose the wrong answer. It happens will all the answer, because the data argument is wrong. That is why no matter the answer, we are always redirected to ‘ineligible.html’.

It is: var jugglingBalls = req.session.data['juggling-balls'] and should be var jugglingBalls = req.session.data['how-many-balls'] as instructed in part 4.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
sebastianczajkowskicommented, Aug 10, 2021

@joelanman @vanitabarrett Thank you very much. I have informed my colleagues and the mentor about the issue and the use of the tutorial on the website instead of the one provided in the download.

I would like to make a suggestion, to place a message on the index.html that says something about the local copy’s tutorial not always being up to date, so it is the first thing that someone new sees.

Best regards, Sebastian

0reactions
vanitabarrettcommented, Aug 10, 2021

Hi @sebastianczajkowski, yes you’re right - unfortunately the main site is updated automatically but the downloaded copy requires the team to manually release any changes in a new version and we don’t always do that straight away. I would suggest trying to use the docs on the website as much as possible. All the docs that are available in the download are also included on the website and, as @joelanman said, are updated more frequently.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Node.js & Express session problem - Stack Overflow
The workaround is to try to give the session middleware as few of the requests as necessary. Here are some tips: Put your...
Read more >
Incorrect typings for session object · Issue #49941 - GitHub
For example doing this: req.session.userId throws an error Property 'userId' does not exist on type 'Session & Partial<SessionData>'.
Read more >
Node JS with Passport Authentication simplified - Medium
The Passport JS framework abstracts the Login process into 2 separate parts, the “session management” (done by the “Passport JS library” ), and...
Read more >
Authenticate Users With Node ExpressJS and Passport.js
This tutorial is part 7 of 7 tutorials that walk through using Express.js for ... request bodies), and express-session (cookie-based session middleware).
Read more >
Session handling in Express Using Redis | Code for geek
To get familiar with Session handling in ExpressJS I recommend to read our first article here. Getting started with Redis : If you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found