As your Node & Express app grows, you will want to organize it into separate route files instead of handling everything inside of one file. The Express router lets you do this, and in this tutorial you will learn how to create individual route files for the Express router. If you are just starting with Node & Express, you may want to go to the beginning of the Node.js for Beginners playlist found here: th-cam.com/play/PL0Zuz27SZ-6PFkIxaJ6Xx_X46avTM1aYw.html
I've watched many NodeJS and express tutorials but the satisfaction I'm getting here, I didn't get before. It's more like I'm gaining confidence in learning the quality content. I first time watched your tutorial on free Code Camp and I decided to come over here.
Separating routes into multiple files is great thing to consider even for small app as nobody knows how complex it can get as you work on it, About Thunder Client extension, it looks more like Postman inside VSCode, but at least you don't have to leave your editor for testing your API, unfortunately the request data is distributed in multiple places and you need to find your way through dozens of tabs to add/edit your params 😵. I liked the plain text way that REST Client extension is using to create requests, it keeps me aware of all the headers needed to make a successful request instead of just implementing them for me automatically, Looking forward for your next video, I always appreciate your way of organizing your code, Thanks Dave 👍
for the static css and js, I think it would be more simple to make only the root serve it and change all the js and css urls by adding a "/" at the beginning. "style/style.css" => "/style/style.css" "js/index.js" => "/js/index.js"
I have a question: Why the object keys of the sent data must have " ". Can't they be without " " ? On React for example when I make a PUT request using the fetch() function, the body of the request does not need the " " for the data object keys. Thank you!
Good question, Laza - you did not provide a timestamp for me to reference, but if I put quotes around the property name of an object, they are likely not needed. You can see examples of Express response objects here: expressjs.com/en/4x/api.html#res.json
Hello Akbar - my extensions do not change when I'm working with Node.js or React or anything else. I do not use many. I do use the Github theme for VS Code. I should make a video on this. 💯
Thanks Dave, I was referring to VS Code extensions such as Eslint, Material icon, Thunder client, etc. Are there others that you use that you find useful?
when i send a post request on thunder client i just receive empty object as the response. but i already send the body same as in the video. how can i fix that?
I came from a background of using python and tornado, what I did was add `app.use(‘/myBaseRoute’, router.getMyBaseRoutes()` and within that file I parse the request.path and use a switch case to pass the route to the appropriate handler, the default being throwing a “route not found” error. Seems a lot cleaner to me honestly
Hi, Dave! I'm at 22:08 working with Thunder Client right now in VS. I selected "Send" for the local host and it's stuck on processing. Would you happen to know the reason for this? Thanks!
im doing internship in company and for nodejs and express im watching your video . i like how to teach ..... and plz don`t do copy paste for small function or tell us where this code we can get . for cors you paste some code .. thank you
Hi IA, we use routers to organize our code. We could code everything in one file, but that would be a mess. We want clean and organized code. The documentation for routers in Express is here: expressjs.com/en/starter/basic-routing.html
the rate at which nodejs is releasing small incremental versions[minuscule, inconsequential] I'll have to hire some dedicated idiot just to keep reminding me and perform the repetitive task.
Super tutorial but i ended up with 'Cannot create property 'next' on string '^/$|/index(.html)?', too much beers for me tonight, will retry tomorrow ;). But i won't give up !
As your Node & Express app grows, you will want to organize it into separate route files instead of handling everything inside of one file. The Express router lets you do this, and in this tutorial you will learn how to create individual route files for the Express router. If you are just starting with Node & Express, you may want to go to the beginning of the Node.js for Beginners playlist found here: th-cam.com/play/PL0Zuz27SZ-6PFkIxaJ6Xx_X46avTM1aYw.html
I've watched many NodeJS and express tutorials but the satisfaction I'm getting here, I didn't get before. It's more like I'm gaining confidence in learning the quality content. I first time watched your tutorial on free Code Camp and I decided to come over here.
Great to hear! 💯
Separating routes into multiple files is great thing to consider even for small app as nobody knows how complex it can get as you work on it,
About Thunder Client extension, it looks more like Postman inside VSCode, but at least you don't have to leave your editor for testing your API,
unfortunately the request data is distributed in multiple places and you need to find your way through dozens of tabs to add/edit your params 😵.
I liked the plain text way that REST Client extension is using to create requests, it keeps me aware of all the headers needed to make a successful request instead of just implementing them for me automatically,
Looking forward for your next video, I always appreciate your way of organizing your code,
Thanks Dave 👍
Thank you Ahmad! Yes, I need to compare Thunder Client vs REST Client vs Postman. I appreciate your feedback.
Cool
a few years late but this was very very helpful, understood everything in this video
Too bad I can't give more than one like. Your teaching is excellent!
Thank you for the kind words! 💯
Thank you so much, Dave, great tutorial
Glad it was helpful!
It is so explained on each concept. I am waiting your advance mern stack project
Thank you, Sumanta! 🙏
Thank you dave, for providing us with such great tutorial. may God bless you.
You're welcome!
Okay lets get it straight and clear these tutorials are gold.
Thank you, Ashish 🙏
for the static css and js, I think it would be more simple to make only the root serve it and change all the js and css urls by adding a "/" at the beginning.
"style/style.css" => "/style/style.css"
"js/index.js" => "/js/index.js"
That could work! 😀 I wanted to demonstrate how static files could be added to any specific directory though. Thanks for the comment! 💯
@@DaveGrayTeachesCode Which might be useful in some cases where a specific route requires some additional or different static files
Thanks a lot Dave !
You're welcome!
amazing tutorial
Holy cow, Thunder Client is so convienient!
I agree! 💯
Great tutorial!! This is awesome. I'm grateful, it helped me so much
Glad it helped!
Amazing tutorial thank you
You're welcome! 🚀
This is great!
Glad it helped!
I have a question: Why the object keys of the sent data must have " ". Can't they be without " " ? On React for example when I make a PUT request using the fetch() function, the body of the request does not need the " " for the data object keys. Thank you!
Good question, Laza - you did not provide a timestamp for me to reference, but if I put quotes around the property name of an object, they are likely not needed. You can see examples of Express response objects here: expressjs.com/en/4x/api.html#res.json
bro yr amaizing
very nice
Thank you, Mujibnagar!
NIce video.
Thanks!
Im stuck on Multiple http methods per route and parameter values section.
my req.body is empty while calling post can anyone help me
am getting an issue , except the get method all other methods are not responding ..its not showing any content to the body
help please anyone
Hi, I'd like to know which other extensions you use when coding nodejs applications
Hello Akbar - my extensions do not change when I'm working with Node.js or React or anything else. I do not use many. I do use the Github theme for VS Code. I should make a video on this. 💯
Thanks Dave, I was referring to VS Code extensions such as Eslint, Material icon, Thunder client, etc. Are there others that you use that you find useful?
I understand. I don't use many though.
How to use it
when i send a post request on thunder client i just receive empty object as the response. but i already send the body same as in the video. how can i fix that?
recently back from stack overflow and i figured out that i forgot to use the express.json() middleware
Glad you found the solution!
@@agus-wesly thanks, i was also facing this problem
I came from a background of using python and tornado, what I did was add `app.use(‘/myBaseRoute’, router.getMyBaseRoutes()` and within that file I parse the request.path and use a switch case to pass the route to the appropriate handler, the default being throwing a “route not found” error. Seems a lot cleaner to me honestly
Can you provide any solution export import of express router as in es6? It'll be helpful
I Googled: es6 import express router ...first result: stackoverflow.com/questions/38550979/importing-exporting-the-express-router-using-es6-import-export-keywords-and-ba
@@DaveGrayTeachesCode Thank you for your support 😎
Hi, Dave! I'm at 22:08 working with Thunder Client right now in VS. I selected "Send" for the local host and it's stuck on processing. Would you happen to know the reason for this? Thanks!
I realized I had ONE THING misspelled. It took two hours of my life to figure that out 🙃 I appreciate your help!
Just saw your comments, but yes, many times it is the little details 😀
@@Alibeee87 hey there , i have same issu , please tell me what you did to fix that problem?
im doing internship in company and for nodejs and express im watching your video . i like how to teach ..... and plz don`t do copy paste for small function or tell us where this code we can get . for cors you paste some code .. thank you
Thank you for the feedback. You can find info for cors by searching for it on npmjs.com 🚀
Sorry could some one please tell me what this line of code means app.use(express.urlencoded({extended: false}))
Docs: expressjs.com/en/5x/api.html#express.urlencoded
Thank you
Which theme is he used??
My theme choices: th-cam.com/users/shortsdp4u1NNFhtE
Please make api node video
That's next! 💯🚀
also
~ u ( K CI/CD
can you make a github cheat for roblox?
Fun suggestion!
Dave i cannot understand why we use routers, i mean what purpose we used it? Give me some docs, please!
Hi IA, we use routers to organize our code. We could code everything in one file, but that would be a mess. We want clean and organized code. The documentation for routers in Express is here: expressjs.com/en/starter/basic-routing.html
@@DaveGrayTeachesCode Thanks, and now i got it. Thanks a lot!!!!!!!!!!!!!!!!!!!!!!!!!!!!
the rate at which nodejs is releasing small incremental versions[minuscule, inconsequential]
I'll have to hire some dedicated idiot just to keep reminding me and perform the repetitive task.
Super tutorial but i ended up with 'Cannot create property 'next' on string '^/$|/index(.html)?', too much beers for me tonight, will retry tomorrow ;). But i won't give up !
You'll get it tomorrow! 💯 Compare to my source code at the course resources link in the description.
You were right, i found my mistake : just wrote router(.....) instead of router.get(....) inside subdir router. It's a shame 🥴
{2023-10-06}