Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. Odd TypeError being thrown.

Odd TypeError being thrown.

Scheduled Pinned Locked Moved JavaScript
javascriptcsharphtmldatabasejson
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dralken
    wrote on last edited by
    #1

    Working on a website in Node.JS, and I've been doing good so far, but I've hit an error that has me stumped.

    TypeError: Cannot set property 'isSubmitted' of undefined
    at app.post.res.locals.showform (/media/sf_Node.js/SmartCage2/user.js:76:25)
    at Layer.handle [as handle_request] (/media/sf_Node.js/SmartCage2/node_modules/express/lib/router/layer.js:95:5)
    at next (/media/sf_Node.js/SmartCage2/node_modules/express/lib/router/route.js:131:13)
    at Route.dispatch (/media/sf_Node.js/SmartCage2/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/media/sf_Node.js/SmartCage2/node_modules/express/lib/router/layer.js:95:5)
    at /media/sf_Node.js/SmartCage2/node_modules/express/lib/router/index.js:277:22
    at Function.process_params (/media/sf_Node.js/SmartCage2/node_modules/express/lib/router/index.js:330:12)
    at next (/media/sf_Node.js/SmartCage2/node_modules/express/lib/router/index.js:271:10)
    at jsonParser (/media/sf_Node.js/SmartCage2/node_modules/body-parser/lib/types/json.js:100:40)
    at Layer.handle [as handle_request] (/media/sf_Node.js/SmartCage2/node_modules/express/lib/router/layer.js:95:5)

    The section that's throwing the error:

    app.get('/login', function (res, req) {
    res.locals.isSubmitted = false;
    res.render("user/login.html");
    });

    The odd thing is, I use the same code above this, and it works.

    app.get('/register', function(req,res) {
    res.locals.isPosted = false;
    res.render("user/register.html");
    });

    I have the forms submitted to the corresponding page (/login to /login, /register to /register), and I use the Nunjucks template system to show relevant data depending on how whether it was accessed via GET or POST. I have no idea why it would be throwing the error on one section, but not the other. I do, however, want to note that I barely know Javascript. I've always used strongly typed languages. I don't even like using 'var' in C#.

    L 1 Reply Last reply
    0
    • D Dralken

      Working on a website in Node.JS, and I've been doing good so far, but I've hit an error that has me stumped.

      TypeError: Cannot set property 'isSubmitted' of undefined
      at app.post.res.locals.showform (/media/sf_Node.js/SmartCage2/user.js:76:25)
      at Layer.handle [as handle_request] (/media/sf_Node.js/SmartCage2/node_modules/express/lib/router/layer.js:95:5)
      at next (/media/sf_Node.js/SmartCage2/node_modules/express/lib/router/route.js:131:13)
      at Route.dispatch (/media/sf_Node.js/SmartCage2/node_modules/express/lib/router/route.js:112:3)
      at Layer.handle [as handle_request] (/media/sf_Node.js/SmartCage2/node_modules/express/lib/router/layer.js:95:5)
      at /media/sf_Node.js/SmartCage2/node_modules/express/lib/router/index.js:277:22
      at Function.process_params (/media/sf_Node.js/SmartCage2/node_modules/express/lib/router/index.js:330:12)
      at next (/media/sf_Node.js/SmartCage2/node_modules/express/lib/router/index.js:271:10)
      at jsonParser (/media/sf_Node.js/SmartCage2/node_modules/body-parser/lib/types/json.js:100:40)
      at Layer.handle [as handle_request] (/media/sf_Node.js/SmartCage2/node_modules/express/lib/router/layer.js:95:5)

      The section that's throwing the error:

      app.get('/login', function (res, req) {
      res.locals.isSubmitted = false;
      res.render("user/login.html");
      });

      The odd thing is, I use the same code above this, and it works.

      app.get('/register', function(req,res) {
      res.locals.isPosted = false;
      res.render("user/register.html");
      });

      I have the forms submitted to the corresponding page (/login to /login, /register to /register), and I use the Nunjucks template system to show relevant data depending on how whether it was accessed via GET or POST. I have no idea why it would be throwing the error on one section, but not the other. I do, however, want to note that I barely know Javascript. I've always used strongly typed languages. I don't even like using 'var' in C#.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Vouksh wrote:

      I barely know Javascript

      Nor me, but the implication of that message is that your res object has not been initialised correctly.

      D 1 Reply Last reply
      0
      • L Lost User

        Vouksh wrote:

        I barely know Javascript

        Nor me, but the implication of that message is that your res object has not been initialised correctly.

        D Offline
        D Offline
        Dralken
        wrote on last edited by
        #3

        Wow, I feel like an idiot. I glanced back over my code... and I had the 'req' and 'res' vars reversed. :doh: But I likely wouldn't have noticed if you didn't point out something with the variables.

        L 1 Reply Last reply
        0
        • D Dralken

          Wow, I feel like an idiot. I glanced back over my code... and I had the 'req' and 'res' vars reversed. :doh: But I likely wouldn't have noticed if you didn't point out something with the variables.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Vouksh wrote:

          I feel like an idiot.

          Something we have all had to admit from time to time.

          E 1 Reply Last reply
          0
          • L Lost User

            Vouksh wrote:

            I feel like an idiot.

            Something we have all had to admit from time to time.

            E Offline
            E Offline
            election commission
            wrote on last edited by
            #5

            me to, hahahaah west bengal voter list

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups