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: kzbin.info/aero/PL0Zuz27SZ-6PFkIxaJ6Xx_X46avTM1aYw
@soniablanche56723 жыл бұрын
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"
@DaveGrayTeachesCode3 жыл бұрын
That could work! 😀 I wanted to demonstrate how static files could be added to any specific directory though. Thanks for the comment! 💯
@ahmad-murery3 жыл бұрын
@@DaveGrayTeachesCode Which might be useful in some cases where a specific route requires some additional or different static files
@quasi_verum Жыл бұрын
Thank you dave, for providing us with such great tutorial. may God bless you.
@DaveGrayTeachesCode Жыл бұрын
You're welcome!
@ahmad-murery3 жыл бұрын
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 👍
@DaveGrayTeachesCode3 жыл бұрын
Thank you Ahmad! Yes, I need to compare Thunder Client vs REST Client vs Postman. I appreciate your feedback.
@mohammedalidelbani5652 жыл бұрын
Cool
@divyanshsharma673 Жыл бұрын
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.
@DaveGrayTeachesCode Жыл бұрын
Great to hear! 💯
@edwilsondasilva99462 жыл бұрын
Too bad I can't give more than one like. Your teaching is excellent!
@DaveGrayTeachesCode2 жыл бұрын
Thank you for the kind words! 💯
@eddiebello95478 ай бұрын
a few years late but this was very very helpful, understood everything in this video
@HologramJay2 жыл бұрын
Holy cow, Thunder Client is so convienient!
@DaveGrayTeachesCode2 жыл бұрын
I agree! 💯
@lazasergiu45582 жыл бұрын
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!
@DaveGrayTeachesCode2 жыл бұрын
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
@funkebello173810 ай бұрын
can you make a github cheat for roblox?
@DaveGrayTeachesCode10 ай бұрын
Fun suggestion!
@ProtikPC_pro_indigo3 жыл бұрын
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.
@sumantakumalik48872 жыл бұрын
It is so explained on each concept. I am waiting your advance mern stack project
@DaveGrayTeachesCode2 жыл бұрын
Thank you, Sumanta! 🙏
@sagarsunil88187 ай бұрын
am getting an issue , except the get method all other methods are not responding ..its not showing any content to the body
@sagarsunil88187 ай бұрын
help please anyone
@gandalfgrey915 ай бұрын
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
@arunkb8276 Жыл бұрын
Im stuck on Multiple http methods per route and parameter values section. my req.body is empty while calling post can anyone help me
@abdulrahmanagboolaosho3582 Жыл бұрын
Sorry could some one please tell me what this line of code means app.use(express.urlencoded({extended: false}))
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
@DaveGrayTeachesCode2 жыл бұрын
Thank you for the feedback. You can find info for cors by searching for it on npmjs.com 🚀
@MohammadBarghamadii2 жыл бұрын
Thank you so much, Dave, great tutorial
@DaveGrayTeachesCode2 жыл бұрын
Glad it was helpful!
@mohammedalidelbani5652 жыл бұрын
How to use it
@amoneleais Жыл бұрын
@assem_ahmed Жыл бұрын
amazing tutorial
@motivational_shorts9429 Жыл бұрын
Can you provide any solution export import of express router as in es6? It'll be helpful
@DaveGrayTeachesCode Жыл бұрын
I Googled: es6 import express router ...first result: stackoverflow.com/questions/38550979/importing-exporting-the-express-router-using-es6-import-export-keywords-and-ba
@motivational_shorts9429 Жыл бұрын
@@DaveGrayTeachesCode Thank you for your support 😎
@agus-wesly2 жыл бұрын
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?
@agus-wesly2 жыл бұрын
recently back from stack overflow and i figured out that i forgot to use the express.json() middleware
@DaveGrayTeachesCode2 жыл бұрын
Glad you found the solution!
@harshitsz814411 ай бұрын
@@agus-wesly thanks, i was also facing this problem
@OnlyGoodVibe_ Жыл бұрын
Which theme is he used??
@DaveGrayTeachesCode Жыл бұрын
My theme choices: kzbin.infodp4u1NNFhtE
@Alibeee872 жыл бұрын
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!
@Alibeee872 жыл бұрын
I realized I had ONE THING misspelled. It took two hours of my life to figure that out 🙃 I appreciate your help!
@DaveGrayTeachesCode2 жыл бұрын
Just saw your comments, but yes, many times it is the little details 😀
@HOW-bt3et3 ай бұрын
@@Alibeee87 hey there , i have same issu , please tell me what you did to fix that problem?
@akbarganey1682 жыл бұрын
Hi, I'd like to know which other extensions you use when coding nodejs applications
@DaveGrayTeachesCode2 жыл бұрын
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. 💯
@akbarganey1682 жыл бұрын
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?
@DaveGrayTeachesCode2 жыл бұрын
I understand. I don't use many though.
@imadbenmadi Жыл бұрын
bro yr amaizing
@ProtikPC_pro_indigo3 жыл бұрын
also ~ u ( K CI/CD
@MujibnagarKhabor2 жыл бұрын
very nice
@DaveGrayTeachesCode2 жыл бұрын
Thank you, Mujibnagar!
@cyberpaimpol2 жыл бұрын
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 !
@DaveGrayTeachesCode2 жыл бұрын
You'll get it tomorrow! 💯 Compare to my source code at the course resources link in the description.
@cyberpaimpol2 жыл бұрын
You were right, i found my mistake : just wrote router(.....) instead of router.get(....) inside subdir router. It's a shame 🥴
@nicolasborges72932 жыл бұрын
Great tutorial!! This is awesome. I'm grateful, it helped me so much
@DaveGrayTeachesCode2 жыл бұрын
Glad it helped!
@sonamohialdin33762 жыл бұрын
Amazing tutorial thank you
@DaveGrayTeachesCode2 жыл бұрын
You're welcome! 🚀
@DeepakGupta-pz4fx3 жыл бұрын
Please make api node video
@DaveGrayTeachesCode3 жыл бұрын
That's next! 💯🚀
@antishandex8984 Жыл бұрын
Thanks a lot Dave !
@DaveGrayTeachesCode Жыл бұрын
You're welcome!
@jorgeloaiza3406 Жыл бұрын
NIce video.
@DaveGrayTeachesCode Жыл бұрын
Thanks!
@ubitubee Жыл бұрын
This is great!
@DaveGrayTeachesCode Жыл бұрын
Glad it helped!
@ashishafk2 жыл бұрын
Okay lets get it straight and clear these tutorials are gold.
@DaveGrayTeachesCode2 жыл бұрын
Thank you, Ashish 🙏
@immortalaigs42032 жыл бұрын
Dave i cannot understand why we use routers, i mean what purpose we used it? Give me some docs, please!
@DaveGrayTeachesCode2 жыл бұрын
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
@immortalaigs42032 жыл бұрын
@@DaveGrayTeachesCode Thanks, and now i got it. Thanks a lot!!!!!!!!!!!!!!!!!!!!!!!!!!!!