This is awesome. You're simplifying usually confusing topics in Express. I love Express for the kind of customization it offers. Add what you need, take out what you don't.
+Derek Shanks Yes, I agree that this is one of the biggest strengths of Express. And I really like it a lot because of this, too. Great to hear you're enjoying the videos :)
My English is not very good, but I have learned a lot. This course gives me the opportunity to learn Nodejs systematically. Thank you for your hard work! From China.
@@jirisrytr6080 There is a change in express-validator since version 6 it's now using something like const { check, validationResult } = require('express-validator'); so that's why you need to rollback in order for this to work.
Max, since I haven't had the opportunity of having your answers on Udemy when I post something on the courses feedback (hoping you can read this instead) I just wanna thank you for all the courses you give and the way you do it, you are by far the best online lecturer I've ever had. Keep on with the good job. Greetings and many thanks all the way from the big Mexico City!
Dude, thank you so much. You made this whole thing just extremely easy to understand, considering that I bumped into this video in total misunderstanding of how express sessions work.Too bad I can`t put"Like" more than once. Nice job!!:D
Ditto, I don't think this course is updated since this was posted in 2016. I would consider newer tutorial, since some of the newer npm package may have been updated which could introduce some breaking changes to the entire stack. Tried to look online for any clues on why but but not much effort. Only way to follow this tutorial correctly, is for Max to show his package.json file and download the exact version of the package that was used when creating this app as to no to run into some weird bug. But you could make it a learning opportunity, by trying to troubleshoot and see if you can find the fix, by going through a couple of the package update and readme, along with breaking changes.
@@rishabhpatel1767 Fix here: stackoverflow.com/questions/12483554/not-able-to-use-express-validator-with-express-3-x in short just do command: npm i --save express-validator@4 It's a version issue.
For those of you having error like " TypeError: expressValidator is not a function" can degrade their express-validator version to remove the error? Type "npm i express-validator@5.3.1" in cmd
I don't have a blog (yet) but this youtube channel + my Udemy presence (www.udemy.com/user/maximilian-schwarzmuller/) provide a lot of free and paid tutorials/ courses :)
you're an allien mn,,,you teach laravel very well, node js very well,,,and i was afraid to learn em all..but i wanna be like youu ..i must know them all.
Hey all i know this video is old so noone may respond but im getting this error when i refresh my page, i am up to 14:00 in the video and dont know why this is happening. If anyone has an idea let me know please, thanks! // Error Code Below // GET / 500 30.803 ms - 743 _http_outgoing.js:481 throw new ERR_HTTP_HEADERS_SENT('set'); ^ Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client at ServerResponse.setHeader (_http_outgoing.js:481:11) at ServerResponse.header (D:\Coding\~JS\PureJs\First App\express-first-app ode_modules\express\lib esponse.js:767:10) at ServerResponse.send (D:\Coding\~JS\PureJs\First App\express-first-app ode_modules\express\lib esponse.js:170:12) at done (D:\Coding\~JS\PureJs\First App\express-first-app ode_modules\express\lib esponse.js:1004:10) at Immediate. (D:\Coding\~JS\PureJs\First App\express-first-app ode_modules\express-handlebars\lib\utils.js:26:13) at runCallback (timers.js:696:18) at tryOnImmediate (timers.js:667:5) at processImmediate (timers.js:649:5)
Thanks for the video ! I have two questions Q1 - How do i access errors for individual fields without looping ? Q2 - How do i pre populate form fields ?
If for example you are using Angular 2 you can make validations in the front end with data driven reactive forms. What is actually better? Doing it in the back end with express?
You absolutely always need to validate on your backend. Frontend validation is nice to have and can improve UX but it also can be tricked (turn of JS for example). Therefore backend validation is super important to avoid getting/ storing invalid data
Express Validator has been updated now you can can't use it this way This is the new way to use express validator express-validator.github.io/docs/ Alternatively you can stay with previous version by running this commands npm uninstall express-Validator npm install express-validator@5.3.0
Hi, I'm having trouble in the router.post function. During the if(error) the stack trace tells me it's undefined. If I put if(req.error) it seems to work, or at least not break. Not sure what I've done wrong. Thanks
Thank you for a great tutorial..! I tried to do this via pug instead of handlebars: if success section(class="success") h2 Successful validation! else if errors section(class="errors") ul each errors li this.msg But i got this error: malformed each.. if i insted do this just to test: each e in errors li e it gives me: e e Because there is two error statements it gives me two e's. But it seems like it can't connect to the inbuilt this.msg and the two error statements using pug?
I found the solution: since the error-msg are objects, we have to retrieve them like so: each val, ind in errors li #{val.msg} ... so instead of this.msg, we can also do val.msg ... Once again, thank you very much for this rich tutorial! looking forward to your course on udemy in near future..
So for some reason - My express is not able to load the stylesheet on the layout.hbs, I do see that the css file is loaded statically from the url directly. localhost:3000/stylesheets/style.css but the way I have applied it on layout.hbs is not working. Can you point out what could be the issue.
Hm, looks good to me. The leading "/" is not needed though, but that shouldn't be the issue. I assume you're getting a 404 error in the JS console upon loading the page, right? Which URL is shown there?
I get a basic html form displayed without any styling, no sure what is the issue, when the stylsheet is displayed from the URL : localhost:3000/stylesheets/style.css I have tried to put absolute path too but still not working, I have tried but none of them works
there were no errors in my console - but I finally figured out a lots of typos in the app.engine method. I guess a good IDE will avoid that but somehow VSCode didnt complain on those. My line was : app.engine('hbs',hbs({extname: 'hbs', defaltLayout: 'layouts', layoutDir: __dirname+'views/layouts/'})); defaultLayout was spelled wrong , also the I had set as layouts instead of file name as layout. I am able to fix it. Thanks
Nice! I have a doubt during the validation of empty password, initially entered email id clears and show the error message of only password field validation. Can you explain about it! Thanks in advance
@16.10 min,when you click on button to check for error message for password the email id will be cleared right, but during error message it will display only about password
I have tried addapting it to the new version of express-validator. I get an extra validation error that I am not sure how to fix.These are really my first steps with Express. I leave the code here in case is useful for someone. On index.js, at the top, import this: var {check, validationResult} = require('express-validator'); and the code for the post request at submit looks like this: router.post('/submit', [ check('email').isEmail().withMessage('Invalid Email'), check("password") .isLength({ min: 4 }) .withMessage('Invalid Password'), check("confirmPassword") .isLength({ min: 4 }) .withMessage('Invalid Password Confirmation') .custom((value,{req, loc, path}) => { if (value !== req.body.password) { // trow error if passwords do not match throw new Error("Passwords don't match"); } else { return value; } }) ], function(req,res,next){ var errors = validationResult(req); if (errors.array().length !== 0){ req.session.errors = errors.array(); req.session.success = false; }else{ req.session.success = true; } res.redirect('/'); });
I'd always do both. Angular 2 for UX, Backend for security. You can always trick the frontend (Angular 2) as it is JS. So in order to make sure that you're not saving invalid data in your database or something like that, also validate on the backend.
I am little confused here. What is the use of session here.? What role does session play here..? How the successful validation page shows up without the form.? Any clarification would be highly appreciated
hi sir, I am getting this error while starting the server. As installtion done successfully. const { checkSchema, validationResult } = require('../check'); ^ SyntaxError: Unexpected token { at exports.runInThisContext (vm.js:53:16) at Module._compile (module.js:387:25) at Object.Module._extensions..js (module.js:422:10) at Module.load (module.js:357:32) at Function.Module._load (module.js:314:12) at Module.require (module.js:367:17) at require (internal/module.js:20:19)
Hi Max , When I add any of these : req.session.errors = null; req.session.sucess = null; the server stops and I have a "Can't set headers after they are sent" error Anyway the code works if I removed them but I don't know why does this happen and what is their importance then.
Yes exactly the same way in the video and here github.com/mschwarzmueller/nodejs-basics-tutorial/blob/master/08-validation-sessions/routes/index.js Is there a problem with that ?
You would need to conditionally render a (for example) in your template where you check if the input above the has an error. That in turn can be checked on the errors you get back from the validator. Also have a look at this link to learn more about the format of the error messages: github.com/ctavan/express-validator#validation-errors
Max! While I send the form request via Post in this excersice, the page stay "waiting for localhost"...is extrange the example in the past excersice (get -post whitout express-valiator/sessions) works fine. Any clue??? As always thanks!
Hi, i have a question. What do you think of writing req.session.success = !errors outside the if using truthy values in js and writing 1 row less? is it a good practice or not?
Dude I love your tutorials! Just a small question: after following ur tutorial all works good, except that is not reading the elements inside the HEAD TAG , nor reading for example: , They just read the .hbs files without slyling, so on.... what do u think is happening? Im saking you this cause in this video I see u paste css style and automatically applies on the localhost... I download ur Repo Nbr 08, im comparing and is almost the same.. pls what do you think is happening? :) hugs!
I don't understand why when I do put action='my method' it takes me to the URL instead of entering the method, I have followed all your tutorials up to now without any problems I don t get why this happens, help please. EDIT: After hours, for some reason I had characters problems. P.D Your tutorials are great
Hello my friend, to me it doesnt have too much sense to add the req.session.errors=null after the render on the 'get' request. it simply doesnt work.It makes sense to put it before to clean the errors when you refresh the page. If you put it after you are always going to get the error messages even when you refresh the page and the fields of the form are going to appear empty but the errors still there. But i still loving your videos :) Madrid
Thanks for the upload. That was so helpful. Are you using atom editor. And what is the package you installed for auto complete/auto suggestion of lib apis
For anyone having the "req.session.errors is undefined" error, you can write this work-around in routes/index.js inside the router.get function (although other solutions might be more elegant): if(req.session.errors) { res.render('index', { title: "Form Validation", success: false, errors: req.session.errors}); } else { res.render('index', {title: "Form Validation", success: false, errors: ""}); } For those using -ejs, this is the loop I use to print the errors:
Thanks for this tutorial. I have followed some of your Python courses as well and appreciate your teaching style. There is something very confusing with this tut though. You install 'express-validator', but you are instead referencing the 'validator.js' module for chaining onto checks. Both are linked in the description. Which one is correct? The 'express-validator' module unfortunately doesn't have a clean and concise list of checks in its documentation, like the module you reference.
Hi Man, With zero knowledge on front end, i learnt something from this tutorial ... Thank you May i know your name ..?? you haven't mentioned anywhere in this tutorial ...
Actually i'm stuck in a situation where i need some suggestions from you ,, here in our project where i'm working , the complete backend is built using nodejs , so i'm planning to build front end using nodejs ,, is my idea good.. if yes how can i interact with api service built using nodejs from front end expreess .. if you didn't get my point ,, please feel free to ask me ..? I need your help Max ..?
3 years later and this is still usefull. Thanks max!
This is awesome. You're simplifying usually confusing topics in Express. I love Express for the kind of customization it offers. Add what you need, take out what you don't.
+Derek Shanks
Yes, I agree that this is one of the biggest strengths of Express. And I really like it a lot because of this, too. Great to hear you're enjoying the videos :)
4 Years Later and this is still very helpfull, thanks!
My English is not very good, but I have learned a lot. This course gives me the opportunity to learn Nodejs systematically. Thank you for your hard work! From China.
Happy to read that Kun and thanks a lot for your comment!
I had an issue with Express Validator that I solved with: npm i --save express-validator@4
Can you mark this comment? It could help many people. :)
@@jirisrytr6080 There is a change in express-validator since version 6
it's now using something like
const { check, validationResult } = require('express-validator');
so that's why you need to rollback in order for this to work.
Thanks, solved my issue
Thank you!
what a great comment
Max, since I haven't had the opportunity of having your answers on Udemy when I post something on the courses feedback (hoping you can read this instead) I just wanna thank you for all the courses you give and the way you do it, you are by far the best online lecturer I've ever had. Keep on with the good job.
Greetings and many thanks all the way from the big Mexico City!
Thanks so much Farid, really amazing to read this and it means a lot to me! I'm very glad to hear that you're enjoying the courses! :)
I just want to say......
Amazing bro I love this channel.
So awesome to read that Mayank, thank you very much for your support!
Dude, thank you so much. You made this whole thing just extremely easy to understand, considering that I bumped into this video in total misunderstanding of how express sessions work.Too bad I can`t put"Like" more than once.
Nice job!!:D
Thanks so much Charlie, it's really great to hear you enjoyed the video! :)
You are my hero! Been learning node js on my own since Jan. and your videos help me so much. Thanks!
Awesome to hear that, thanks so much!
Such a great teacher! This stuff is usually hard for me to learn, so I'm happy to have found this.
Great to read that the video helps to make things easier for you Christian, thank you for sharing this!
man these videos are awesome. really appreciate you taking time to do these
Great to hear you're liking them Siddhardha! :)
One more awesome tutorial! Keep on doing this, please. Your channel will increase a lot, for sure. Thanks from Brazil.
+Igor Vidotto Felipe
I will, no worries. :)
Indeed, a Very Good Tutorial friend.. Thanks from India
you are a awesome teacher, im glad to have found your chanel, regards from El Salvador
+Raul Lopez
It's awesome to hear this, thanks so much Raul!
great I got errors and listed them but If I want to show them under every corresponding field then how can I do that?
I have a error coming. (expressValidator not a function).how will solve
Ditto, I don't think this course is updated since this was posted in 2016. I would consider newer tutorial, since some of the newer npm package may have been updated which could introduce some breaking changes to the entire stack.
Tried to look online for any clues on why but but not much effort.
Only way to follow this tutorial correctly, is for Max to show his package.json file and download the exact version of the package that was used when creating this app as to no to run into some weird bug.
But you could make it a learning opportunity, by trying to troubleshoot and see if you can find the fix, by going through a couple of the package update and readme, along with breaking changes.
same error i also have pls post solution if anyone got it
@@rishabhpatel1767 Fix here: stackoverflow.com/questions/12483554/not-able-to-use-express-validator-with-express-3-x
in short just do command: npm i --save express-validator@4
It's a version issue.
For those of you having error like "
TypeError: expressValidator is not a function" can degrade their express-validator version to remove the error?
Type "npm i express-validator@5.3.1" in cmd
I also have same problem
Mad respect to you buddy!
Thanks so much - I'm really happy you liked it!
Thank you man! Where can I find more tutorials or blogs by you?
I don't have a blog (yet) but this youtube channel + my Udemy presence (www.udemy.com/user/maximilian-schwarzmuller/) provide a lot of free and paid tutorials/ courses :)
Thank you! You're truly awesome man!
Hard work can easily be seen behind you videos. Kudos, man
These videos are so helpful. You rule man.
Really happy to hear that, thanks so much Michael!
What's the hotkey you use @8:57 to hightlight and edit the same attribute value?
Great video. I learned a lot. You are so positive and awesome. I love learning from you!
Really happy to read that you like the content and the teaching style, thank you very much Paul :)
These videos are awesome. Keep up the amazing work!!
Thank you very much Miroslav, I'll try my best to keep it up!
How to make the form preserve the data on failed validation?
you're an allien mn,,,you teach laravel very well, node js very well,,,and i was afraid to learn em all..but i wanna be like youu
..i must know them all.
Thanks a lot for this great feedback! But no worries, I'm not an alien, I guess I just enjoy learning new technologies :)
Hey all i know this video is old so noone may respond but im getting this error when i refresh my page, i am up to 14:00 in the video and dont know why this is happening.
If anyone has an idea let me know please, thanks!
// Error Code Below //
GET / 500 30.803 ms - 743
_http_outgoing.js:481
throw new ERR_HTTP_HEADERS_SENT('set');
^
Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
at ServerResponse.setHeader (_http_outgoing.js:481:11)
at ServerResponse.header (D:\Coding\~JS\PureJs\First App\express-first-app
ode_modules\express\lib
esponse.js:767:10)
at ServerResponse.send (D:\Coding\~JS\PureJs\First App\express-first-app
ode_modules\express\lib
esponse.js:170:12)
at done (D:\Coding\~JS\PureJs\First App\express-first-app
ode_modules\express\lib
esponse.js:1004:10)
at Immediate. (D:\Coding\~JS\PureJs\First App\express-first-app
ode_modules\express-handlebars\lib\utils.js:26:13)
at runCallback (timers.js:696:18)
at tryOnImmediate (timers.js:667:5)
at processImmediate (timers.js:649:5)
I found out why, its cause i did: RES.session.errors not REQ.session.errors
I am having error req.session.touch() is not a function
Should I downgrade me express-session??
i use ejs ... how i can convert each statement ?
Excellent tutorial Max. Learned a lot ;)
Really happy to read that, thanks so much for sharing this :)
where is session part?
Thanks for the video !
I have two questions
Q1 - How do i access errors for individual fields without looping ?
Q2 - How do i pre populate form fields ?
i am having an error route.get() requires a callback but got a [object undefined]
If for example you are using Angular 2 you can make validations in the front end with data driven reactive forms. What is actually better? Doing it in the back end with express?
You absolutely always need to validate on your backend. Frontend validation is nice to have and can improve UX but it also can be tricked (turn of JS for example). Therefore backend validation is super important to avoid getting/ storing invalid data
Thank you! That was fast :)
How to check email exitst? Please help me
getting error, on app.use(expressValidator()); line, the error is "cannt use expressValidator as method". can anybody help me?
Express Validator has been updated now you can can't use it this way This is the new way to use express validator express-validator.github.io/docs/
Alternatively you can stay with previous version by running this commands
npm uninstall express-Validator
npm install express-validator@5.3.0
Love your accent and of course you are a great teacher
Awesome to read that you like both the content and the accent vignesh ;)
Hi, I'm having trouble in the router.post function.
During the if(error) the stack trace tells me it's undefined.
If I put if(req.error) it seems to work, or at least not break.
Not sure what I've done wrong.
Thanks
nvm I'm dumb
Nah, I don't think so ;) Nonetheless, great to hear that everything seems to be working now!
How do you get the colouring and autocomplete for handlebars?
can anyone tell me how to use ejs with if and else in showing error messages
Thank you for a great tutorial..!
I tried to do this via pug instead of handlebars:
if success
section(class="success")
h2 Successful validation!
else
if errors
section(class="errors")
ul
each errors
li this.msg
But i got this error: malformed each..
if i insted do this just to test:
each e in errors
li e
it gives me:
e
e
Because there is two error statements it gives me two e's. But it seems like it can't connect to the inbuilt this.msg and the two error statements using pug?
I found the solution: since the error-msg are objects, we have to retrieve them like so:
each val, ind in errors
li #{val.msg} ... so instead of this.msg, we can also do val.msg ...
Once again, thank you very much for this rich tutorial! looking forward to your course on udemy in near future..
How's the "{{varName}}" thing called? Where you pass a json at res.render(renderView?, json, callback);
Can indentation inconsistency break handlebars, was getting error on the form.
Awesome Tutorial SIR :-)
seriously loved it :-)
So happy to read that, thank you so much akshay :)
Oh man, u explained it so well...thanks a ton
Thanks so much for your great feedback!
So for some reason - My express is not able to load the stylesheet on the layout.hbs, I do see that the css file is loaded statically from the url directly.
localhost:3000/stylesheets/style.css
but the way I have applied it on layout.hbs is not working. Can you point out what could be the issue.
Hm, looks good to me. The leading "/" is not needed though, but that shouldn't be the issue.
I assume you're getting a 404 error in the JS console upon loading the page, right? Which URL is shown there?
I get a basic html form displayed without any styling, no sure what is the issue, when the stylsheet is displayed from the URL : localhost:3000/stylesheets/style.css
I have tried to put absolute path too but still not working, I have tried but none of them works
Do you see any errors in your dev console? (Developer tools console)
there were no errors in my console - but I finally figured out a lots of typos in the app.engine method. I guess a good IDE will avoid that but somehow VSCode didnt complain on those.
My line was : app.engine('hbs',hbs({extname: 'hbs', defaltLayout: 'layouts', layoutDir: __dirname+'views/layouts/'}));
defaultLayout was spelled wrong , also the I had set as layouts instead of file name as layout. I am able to fix it.
Thanks
Love your videos dude! Thanks!
Thanks Abdul, so awesome to hear that!
Nice!
I have a doubt during the validation of empty password, initially entered email id clears and show the error message of only password field validation. Can you explain about it!
Thanks in advance
Sorry, I didn't quite get your question. You're not seeing all validation errors, is that it?
@16.10 min,when you click on button to check for error message for password the email id will be cleared right, but during error message it will display only about password
Ah okay - yes the old value gets deleted here. If you want to keep that, you would need to pass back the valid values to your view.
Great TEACHER! Keep it up!
Thanks a lot Alejandro, I'll try my best to do so!
great videos! what is the best way to keep the form elements retain the values entered when there are errors? thx.
This seems to work ok. Welcome any critiques! :)
router.get('myRoute', function(req, res) {
res.render('myView', {csrfToken: req.csrfToken(), success: req.session.success, errors: req.session.errors, data: req.session.data });
req.session.errors = null;
req.session.success = null;
});
router.post('myRoute', function(req, res, next) {
.. do error checking...
...
var errors = req.validationErrors();
if(errors) {
req.session.errors = errors;
req.session.success = false
req.session.data = req.body;
} else {
req.session.success = true;
}
res.redirect('myRoute'');
}
spent 3 hours trying to write the same index.hbs code in jade/pugjs and i still cant get it to work. im about to kms this is so frustrating
Errors are always all undefined for me. I can access req.body.whateverfield but the check and checkbody do not work
I got an error that "'errors' property is not defined".
and the above line appears instead of sign up form
I have tried addapting it to the new version of express-validator. I get an extra validation error that I am not sure how to fix.These are really my first steps with Express. I leave the code here in case is useful for someone. On index.js, at the top, import this: var {check, validationResult} = require('express-validator'); and the code for the post request at submit looks like this:
router.post('/submit',
[
check('email').isEmail().withMessage('Invalid Email'),
check("password")
.isLength({ min: 4 })
.withMessage('Invalid Password'),
check("confirmPassword")
.isLength({ min: 4 })
.withMessage('Invalid Password Confirmation')
.custom((value,{req, loc, path}) => {
if (value !== req.body.password) {
// trow error if passwords do not match
throw new Error("Passwords don't match");
} else {
return value;
}
})
],
function(req,res,next){
var errors = validationResult(req);
if (errors.array().length !== 0){
req.session.errors = errors.array();
req.session.success = false;
}else{
req.session.success = true;
}
res.redirect('/');
});
hello sir i am not getting the validation part
Is it better to do the validations in Angular or in the Backend?
I'd always do both. Angular 2 for UX, Backend for security. You can always trick the frontend (Angular 2) as it is JS. So in order to make sure that you're not saving invalid data in your database or something like that, also validate on the backend.
That's an excellent point! I was thinking the same. Thanks again. But i have another question. How do you prevent XSS attacks in a MEAN 2 form?
Angular 2 should automatically sanitize any HTML you output through some kind of databinding.
Thanks
I am little confused here.
What is the use of session here.?
What role does session play here..?
How the successful validation page shows up without the form.?
Any clarification would be highly appreciated
watch quality content - there are many videos on this channel or similiar channels with high subscriber numbers but it's 90% bad content
Which was the last video??
You can find the full playlist here => academind.com/learn/node-js/the-basics/
How come you're posting to '/submit' but the url that you're posting to is '/'?
But this is better to be done by the client side ?
hi sir, I am getting this error while starting the server. As installtion done successfully.
const { checkSchema, validationResult } = require('../check');
^
SyntaxError: Unexpected token {
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:387:25)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:20:19)
I had to Subscribe because you are the coolest dude thank you!!!
Haha, so amazing - thanks so much Elvin! :)
Hi Max ,
When I add any of these :
req.session.errors = null;
req.session.sucess = null;
the server stops and I have a "Can't set headers after they are sent" error
Anyway the code works if I removed them but I don't know why does this happen and what is their importance then.
Do you maybe call res.render() before setting that?
Yes exactly the same way in the video and here
github.com/mschwarzmueller/nodejs-basics-tutorial/blob/master/08-validation-sessions/routes/index.js
Is there a problem with that ?
No, as res.redirect('/') gets called after that it should work fine. But the exact same code gives you this error? :/
How do you output the errors below the specific input?
You would need to conditionally render a (for example) in your template where you check if the input above the has an error. That in turn can be checked on the errors you get back from the validator. Also have a look at this link to learn more about the format of the error messages: github.com/ctavan/express-validator#validation-errors
Thank you man! I needed this :D
Awesome to hear you enjoyed it Esteban!
Wunderbar.. Ich mag es sehr. Mega geil
Das freut mich sehr :)
Brother pl help ! express session is working in postman, but not working in browser. but session is being set in browser. am I making any mistake ?
He said NodeJS sets the cookie on the server in memory.
Thank you. Lets see after setting the cookie
Sarada Prasad Midde ...but you can install other modules if you want to store on the server.
my views data is in a pug format. how can i use these if conditions there?
obviously, you would had referred to the pug documentation.
Hi Max, any ideas on how to implement session renewal in express ? Thanks.
Error: Failed to lookup view "error" in views directory
this is an expressjs error, put
app.set("views", "./views");
after the line - const app = express();
Max! While I send the form request via Post in this excersice, the page stay "waiting for localhost"...is extrange the example in the past excersice (get -post whitout express-valiator/sessions) works fine. Any clue??? As always thanks!
Hard to tell - did you compare your code to mine (you can find a link to it in the video description). Maybe some infinite loop you're entering.
Done, I want finised the error handler in the controller :) Works !!! Thanks again and I enjoy watching ads before your tutorials!!! ;)
Great to hear ;)
Thanks Max!, really helpful
It is so great to read that I could help, thanks so much Abhishek!
I was getting "cant find the error in views" error and when I fixed it I kept getting Get 500 on my console, I still dont know why.
Hi, i have a question. What do you think of writing req.session.success = !errors outside the if using truthy values in js and writing 1 row less? is it a good practice or not?
Sir,
Is there any function like Laravel dd( ) in Nodejs(express.js )?
max , why not use client side validation ?
Doesn't suffice, users can bypass it (e.g. turn off JS, manipulate your code).
Perfect! Thanks Max.
Thank YOU Nikola, happy to read that you like it!
can i ask u something?why u send the errors with session ?can we send it with render object?like res.render('home',{msg:errors})
Yes, you could also do this, however I try to only send data via render() which is always there. That might not be the case for errors.
Mindspace thanks u my idol
Great video!
Thank you David!
I guess this channel values quantity more than quality
What? Sorry but this is a really insulting comment considering the fact that you get more than 500 high quality videos for free here.
Dude I love your tutorials!
Just a small question: after following ur tutorial all works good, except that is not reading the elements inside the HEAD TAG , nor reading for example: , They just read the .hbs files without slyling, so on.... what do u think is happening?
Im saking you this cause in this video I see u paste css style and automatically applies on the localhost... I download ur Repo Nbr 08, im comparing and is almost the same.. pls what do you think is happening? :) hugs!
TOP! One thing: The link at the top "Possible session storages" is not correct!
The screen text is making it hard to view the code sometime.
What a beautiful smile on your face :-)
Thanks Babar ;)
I got lost on importing the styling. I thought you just copied a previous folder of which that particular styling was not included. Did I miss a step?
Yes I just went into folder 8 on the repo and copied the css file.
I don't understand why when I do put action='my method' it takes me to the URL instead of entering the method, I have followed all your tutorials up to now without any problems I don t get why this happens, help please.
EDIT:
After hours, for some reason I had characters problems.
P.D
Your tutorials are great
What is the name of the style sheet used here and where on github is it?
Github repo > 08-validation > public/stylesheets (github.com/mschwarzmueller/nodejs-basics-tutorial/tree/master/08-validation-sessions/public/stylesheets)
What a great guide! One of the best on the web.
How do you get ****** when you type in the password? Mine password fields comes with plain text.
Happy to hear you're liking it. The *** is the default behavior if you set the to type="password" =>
app.use(expressValidator()) is not working
How did you solve this problem ?
Hello my friend, to me it doesnt have too much sense to add the req.session.errors=null after the render on the 'get' request. it simply doesnt work.It makes sense to put it before to clean the errors when you refresh the page. If you put it after you are always going to get the error messages even when you refresh the page and the fields of the form are going to appear empty but the errors still there. But i still loving your videos :) Madrid
sir plzzz make video on image validation using express validator
I can finally go to sleep. Thank you!!!
Good night Niccu ;)
Thanks for the upload. That was so helpful. Are you using atom editor. And what is the package you installed for auto complete/auto suggestion of lib apis
He is using webstorm or php storm
Yep, exactly :)
Those editor colors remind me of my first programming course in Turbo Pascal. Can you share the color codes in paste bin or something?
For anyone having the "req.session.errors is undefined" error, you can write this work-around in routes/index.js inside the router.get function (although other solutions might be more elegant):
if(req.session.errors) {
res.render('index', { title: "Form Validation", success: false, errors: req.session.errors});
} else {
res.render('index', {title: "Form Validation", success: false, errors: ""});
}
For those using -ejs, this is the loop I use to print the errors:
Thanks for this tutorial. I have followed some of your Python courses as well and appreciate your teaching style. There is something very confusing with this tut though. You install 'express-validator', but you are instead referencing the 'validator.js' module for chaining onto checks. Both are linked in the description. Which one is correct? The 'express-validator' module unfortunately doesn't have a clean and concise list of checks in its documentation, like the module you reference.
Now its modified please tell the new one
thank You So much for these videos....!
Please Uplode Video on node pagination.
Happy to read that you like the videos Osama! I might create more Node content in the future, thanks for the suggestion.
Hi Man,
With zero knowledge on front end, i learnt something from this tutorial ...
Thank you
May i know your name ..??
you haven't mentioned anywhere in this tutorial ...
Thanks so much for your wonderful feedback Manjunath, really happy to read that you liked the video. I'm Max :)
Actually i'm stuck in a situation where i need some suggestions from you ,,
here in our project where i'm working , the complete backend is built using nodejs , so i'm planning to build front end using nodejs ,, is my idea good..
if yes how can i interact with api service built using nodejs from front end expreess ..
if you didn't get my point ,, please feel free to ask me ..?
I need your help Max ..?
Hi! Great Video!
I have a question, is there any client-side validator for express js?
Not really - you can use any JS validation library though.
good.. thanks guys >>>> god job
You are awesome!
Thank you so much Tonnie - you and all the other viewers are, you make the channel what it is :)