Author's Index/Create/New Routes - Node.js/Express/MongoDB Course #2

  Рет қаралды 113,179

Web Dev Simplified

Web Dev Simplified

Күн бұрын

Пікірлер: 415
@atharvabansod6775
@atharvabansod6775 Жыл бұрын
for thos who got error in ...model.prototype.save() no longer accepts a callback instead of this: 👇👇👇 author.save((err,newAuthor)=>{ if(err){ res.render('authors/new',{ author: author, errMessage:'Error Creating Author...' }) }else{ res.render('authors') } }) use this:👇👇👇 author.save(). then((newAuthor)=>{ res.render('authors') }). catch((err)=>{ res.render('authors/new',{ author: author, errMessage:'Error Creating Author...' }) }) Best Go... ! 👍
@trentasaurus
@trentasaurus Жыл бұрын
Thank you!
@vadimsmamedovs
@vadimsmamedovs 10 ай бұрын
thanks
@SolveForBetter
@SolveForBetter 8 ай бұрын
Much obliged : )
@dupolo5358
@dupolo5358 2 ай бұрын
worked here, thanks
@learningwithtabrez
@learningwithtabrez 3 жыл бұрын
Excellent brother, no one can give such knowledge in such a simple and easy way..
@holup5035
@holup5035 3 жыл бұрын
This is my 4th day of learning back end webdev and this code and code from last episode works fine for me buuuut I understand a null from this 😅 I hope in like month or so I can go back to this comment and fairy reply to it as I understand and can create simply fullstack website on my own. :D
@IGIRIIS
@IGIRIIS 2 жыл бұрын
Every thing is named author or authors that is confusing and hard to understand for complete beginner , but still it's a great course
@Antel_007
@Antel_007 4 ай бұрын
Please try to update this playlist
@nithinkottary9578
@nithinkottary9578 4 жыл бұрын
can we do the html part using front end?
@MonsterFishKeepersPH
@MonsterFishKeepersPH 2 жыл бұрын
WTF just happened, the only problem was const Author, the Author's color was null and when I deleted the name and retype Author again the program worked fine now. can someone explain what happened? I even undid the steps to make sure if it was really spelled Author in the first place and it really was! What happened?
@mamusthafa6
@mamusthafa6 2 жыл бұрын
Getting this error... { %> authors.forEach is not a function
@tobyapellido1527
@tobyapellido1527 2 жыл бұрын
you missed a - inside your ejs logic,
@javhaasuhochir8126
@javhaasuhochir8126 2 жыл бұрын
did you find your solution? I am getting that error too.
@trendingtopics2888
@trendingtopics2888 Жыл бұрын
@@javhaasuhochir8126 Did you find solution authors.forEach is not a function I am getting that error too.
@trendingtopics2888
@trendingtopics2888 Жыл бұрын
Did you find solution authors.forEach is not a function I am getting that error too.
@surfinbird71
@surfinbird71 4 жыл бұрын
If you get the "errorMessage is not defined" error don't freak out. As he explains late in the video you can put this in errorMessage.ejs:
@miralpankhania3983
@miralpankhania3983 4 жыл бұрын
Thank you so much for help!!
@sagar_khanapurkar
@sagar_khanapurkar 4 жыл бұрын
Thank you!
@tejasjoshi1907
@tejasjoshi1907 4 жыл бұрын
I am getting TypeError: cannot read the property ' name ' of undefined Why? Can u please pleaee help mee
@claudiutamas79
@claudiutamas79 2 жыл бұрын
The app get to this point multiple times, but only when we have a message it show it - I understand now. Thanks!
@DEV_1024
@DEV_1024 2 жыл бұрын
you saved my time.. Thanks a lot !!!
@Anas-wp1pi
@Anas-wp1pi 4 жыл бұрын
19:45 i followed exactly your steps but it keeps saying that errorMessage is undefined never mind i fixed it, instead of doing res.render(`authors`, { errorMessage : `something went wrong`}) declare the an object first containing them : let locals = { errorMessage : `something went wrong` } then res.render(`authors`, locals) then in errorMessage.ejs :
@tr4shp4nda_ttv
@tr4shp4nda_ttv 4 жыл бұрын
I noticed I got the error when I mistakenly put !== instead of != in the IF statement
@brighga33
@brighga33 4 жыл бұрын
Thank you for contributing your solution! I run into the same issue as you did and fixed it using your solution here. My coded differs from yours in that I didn't additionally declare a variable to contain the errorMessage. I think the problem here is that every local variable defined in the res.render actually belongs to res.locals and it should be made explicit by setting it to be when passing to the view.
@amartrem
@amartrem 4 жыл бұрын
@@brighga33 Thanks - works for me :)
@brighga33
@brighga33 4 жыл бұрын
@@amartrem glad I could help! Big shoutout to Kyle for his great content. :)
@AntonyAllocious
@AntonyAllocious 4 жыл бұрын
@@brighga33 - Thanks Man- You save me
@JoeWong81
@JoeWong81 5 жыл бұрын
You have a solid teaching and explanation style bro!!! your channel definitely deserves more views
@WebDevSimplified
@WebDevSimplified 5 жыл бұрын
Thanks!
@deathvall3y
@deathvall3y 5 жыл бұрын
Hard to find good content like this as youtube search algorithm is messed up and filled up with promotions.
@shrillrock
@shrillrock Жыл бұрын
for those getting the MongooseError: Model.prototype.save() no longer accepts a callback error, add a .then() after the .save() and put everything in the then() function like he does for the save() in the video
@nadeemkallungal1884
@nadeemkallungal1884 Жыл бұрын
thank you so much for the help!
@bikebro7747
@bikebro7747 11 ай бұрын
I had to remove the "err" and only keep the "newAuthor" callback parameter for it to work. The "err" was being passed the saved object and being read as true in the if statement
@shoeshiner9027
@shoeshiner9027 4 жыл бұрын
I found playback speed = 0.75x is suitable for me. Nice jobs.
@ShivamSingh-kn3gz
@ShivamSingh-kn3gz 3 жыл бұрын
Same for me dude,
@IYIrOWN
@IYIrOWN 3 жыл бұрын
Oi my whole study group said the same xD
@Sparta155
@Sparta155 3 жыл бұрын
Great tip.
@agnieszkalewandowska9896
@agnieszkalewandowska9896 4 жыл бұрын
Explaining every line **.** Even every single tiny thing you use. You are a teaching god! :D
@Kay8B
@Kay8B 3 жыл бұрын
At 16:00 you no longer need bodyParser as its built into express now. So it would look like: const express = require('express'); app.use(express.urlencoded({ extended: true })); app.use(express.json());
@BL-ki9qm
@BL-ki9qm 3 жыл бұрын
THANK YOU: to elaborate the line of code is now "app.use(express.urlencoded({ limit: '10mb', extended: false}))"
@TheGungoBlue
@TheGungoBlue 3 жыл бұрын
Much thanks to both of you. I was about to spend more time looking for a non-deprecated alternative.
@tewodrosmengistie4133
@tewodrosmengistie4133 4 жыл бұрын
Bruh why does webdev have to be so complicated
@peopleyoumustknow1325
@peopleyoumustknow1325 3 жыл бұрын
I am crying in error
@ahmedboutaraa8771
@ahmedboutaraa8771 4 жыл бұрын
i don't really know why people pay money for coursers to get garbage instead of watching free stuff like this on youtube and i really want to see more helpful content like this you're blessed bro
@BroomieHERE
@BroomieHERE 22 күн бұрын
Certificates
@ritaaktay2502
@ritaaktay2502 2 жыл бұрын
Hi, thanks for this awesome tutorial! One question on the locals object: "The res.locals is an object that contains the local variables for the response, scoped to the request so only available for the views rendered during that request/response cycle." hence we get an "errorMessage undefined" error if we include it in layout.ejs and thus on pages where the call to render didn't include an errorMessage option. errorMessage is undefined, but locals.errorMessage is null. So instead of if (locals.errorMessage != null) we can have just inside the errorMessage.ejs and it will work the same way by either print nothing or the error message. Is there something I am overlooking in this option or have I understood correctly?
@ActiveZeni
@ActiveZeni 5 жыл бұрын
Great Video! As of Express version 4.16 you don't have to install bodyparser depency since its now bundled with Express.
@WebDevSimplified
@WebDevSimplified 5 жыл бұрын
Good point. I for some reason only thought express.json() was a part of express and the urlencoded function was left out.
@Aman-Verma
@Aman-Verma Жыл бұрын
@@WebDevSimplified Hi Kyle! Is there any plan for updated full stack course either on youtube or your website?
@vrk4052
@vrk4052 3 жыл бұрын
When I run the app locally it runs as expected, but when I run it on Heroku it seems to give me an error when I try to add an author. I did the IP 0.0.0.0/0 address step. But not sure what is causing the error? @Web Dev Simplified
@valentina711
@valentina711 3 жыл бұрын
same problem here. Could you fix it? I can connect to atlas mongo db from my computer in dev mode, and the users were created just fine. But it doesn't work in heroku. UPDATE: it was a typo in the environment variable heroku config😅. Everything works perfect now, thank for this amazing tutorial!
@tesicaleksa6746
@tesicaleksa6746 2 жыл бұрын
For those who get an error at 16:49 "name is not defined", u need to include app.use(bodyParser...) before u do app.use(author.router) So, basically instead of: app.use(indexRouter) app.use('/authors',authorRouter) app.use(express.static('public')) app.use(bodyParser.urlencoded({limit:'10mb',extended:true})) , you should do: app.use(bodyParser.urlencoded({limit:'10mb',extended:true})) app.use(indexRouter) app.use('/authors',authorRouter) app.use(express.static('public')
@saurabhdeshmukh9587
@saurabhdeshmukh9587 2 жыл бұрын
damn i wasted a few days for this error...thanks a lot man! Here have an imaginary cookie!
@illusion287
@illusion287 2 жыл бұрын
ty man
@erfanabac
@erfanabac 9 ай бұрын
I love you😭😭😭😭❤❤
@beksaylor
@beksaylor Жыл бұрын
With the errorMessage ERROR, I just put it like this............Then I no longer got the not define error.
@programmertik2046
@programmertik2046 3 жыл бұрын
Hey guys to all those who are facing error message not displlayed plz check if there is a space in your input field ,if it is there then the single space entry is goin in your database .
@Mammoth17
@Mammoth17 3 жыл бұрын
For heroku Config Vars don't forget to erase "" when typing in your mongo password. I used "" instead of "password".
@jimmoriya
@jimmoriya 2 жыл бұрын
thank you! I did the same and couldn't managed to find it myself!
@vidhinagda6445
@vidhinagda6445 4 жыл бұрын
How can I add and save multiple fields for Author model? I created the model with all the required fields and I also modified the routes --> authors.js But I am getting an error while creating author. My try block is not getting executed, the error is catched and it says 'Error creating new author'
@sofiyamathew5587
@sofiyamathew5587 2 жыл бұрын
did u get the answer? pls help if u found whats error im getting the same erroe
@alessandramiazato
@alessandramiazato 4 жыл бұрын
Thank you so much for this course, Im trying to get a job as web dev and your videos are so rich in content it's a great first step before reading that massive documentation I loved those three first videos explaining right to the point concepts that anyone else takes at least 15 min haha
@romimaximus
@romimaximus 5 жыл бұрын
i never learned so much in one turorial..thank you that was a awesome video...You just got my respect and a great fan...!!
@WebDevSimplified
@WebDevSimplified 5 жыл бұрын
Thank you so much! I am really glad you enjoyed the video and learned a bunch from it.
@sauravkumarsonu829
@sauravkumarsonu829 3 жыл бұрын
Awesome content, It's superb, i found the best thing ever, love you Kyle, but I'm facing an error : When I'm searching for the authors, nothing happens🙄, please guide me
@tea_and_aangilam
@tea_and_aangilam 3 жыл бұрын
Hope you found the issue. I faced a similar problem.. but I had a bug, shown below.. const authors = await Author.find( { searchOptions } ); It has to be.. const authors = await Author.find( searchOptions ); (I tried debugging by displaying the searchOptions and authors fields.)
@oussamaelharmali2294
@oussamaelharmali2294 4 жыл бұрын
That's the power of JS guy's, I'm a java developer but I just fall in love with javascript such a good and useful lang - thanks for your tuto (y)
@kelvinmugo8977
@kelvinmugo8977 3 жыл бұрын
in new.ejs and in _form_fields causing errors.first one says reference error,second says author not defined.whats up?
@xenoaurora
@xenoaurora 3 жыл бұрын
Did you ever find a fix for this?
@kelvinmugo8977
@kelvinmugo8977 3 жыл бұрын
@@xenoaurora yes sure thanks
@datatalkshassan
@datatalkshassan 3 жыл бұрын
@@kelvinmugo8977 how did you fix this? I'm getting the same error
@devviz
@devviz 2 жыл бұрын
@@kelvinmugo8977 how??
@aviralgupta9364
@aviralgupta9364 4 жыл бұрын
At 16.42 i am getting Create output. as I write command res.send("Create") but as soon as i send res.send(req.body.name) error is coming TypeError: Cannot read property 'name' of undefined I have installed body-parser too and followed your each step till this time. Please help !!!
@ras1280
@ras1280 4 жыл бұрын
you must be doing something wrong in the authors.js file, when creating a new author. But either way, you can delete that value=
@shahnawazshaikh6960
@shahnawazshaikh6960 4 жыл бұрын
you have to implement the bodyparser to the server before the you define the routes. The order matters!
@zakriajanjua9170
@zakriajanjua9170 3 жыл бұрын
it gives me error searchOptions is not defined pointing towards the index.ejs file when i create new author but it still creates the author in the database. What is the problem?
@calebzhou2922
@calebzhou2922 4 жыл бұрын
I have a bug at 31:23, searchOptions.name is not found in the index.ejs page. Anyone face this, please?
@sauravkumarsonu829
@sauravkumarsonu829 3 жыл бұрын
I am facing the same problem
@sauravkumarsonu829
@sauravkumarsonu829 3 жыл бұрын
Have you solved this issue, can you let me know please
@rexparker6011
@rexparker6011 4 жыл бұрын
at 22:45 on the line that reads: "const newAuthor = await author.save()". I was perplexed that there was no explicit reference to the DB connection created earlier in server.js until I found this webpage: --------------------- Mongoose Schema vs. Model let mongoose = require('mongoose') This reference will be the same as the one that was returned when we connected to the database, which means the schema and model definitions will not need to explicitly connect to the database. --------------------- And that cleared it up nicely. Here's a link to page: www.freecodecamp.org/news/introduction-to-mongoose-for-mongodb-d2a7aa593c57/
@targetproof8
@targetproof8 4 жыл бұрын
I got the same error as you reference below. I tried adding let mongoose = require('mongoose') to server.js file and it wasn't that simple. I got SyntaxError: "Identifier 'mongoose' has already been declared." Any suggestions? [nodemon] starting `node server.js` F:\Apps ode.express.mongodb outes\authors.js:21 const newAuthor = await author.save() ^^^^^ SyntaxError: await is only valid in async function at Module._compile (internal/modules/cjs/loader.js:721:23) at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3) at Module.require (internal/modules/cjs/loader.js:690:17) at require (internal/modules/cjs/helpers.js:25:18) at Object. (F:\Apps ode.express.mongodb\server.js:11:22) at Module._compile (internal/modules/cjs/loader.js:776:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
@EriX-AI-FREE-Team
@EriX-AI-FREE-Team 3 жыл бұрын
Thanks for this good content! This is the first time for me to use mongodb, I did encounter a problem, and it's solved. (see below) Hope this comment could help out other viewers in the future. Note: Probably specifically to the users on Windows 10, Not sure. = = = = = = = = = [Problem] = = = = = = = = = At 19:48, after clicking Create Btn, my page just stuck in the same page (without navigating to localhost://3000/authors) = = = = = = = = = [What I did] = = = = = = = = = 1. In routes/authors.js, right below the line with 【if (err) {】, I added 【console.log(err)】 because I wanted to know what happened. 2. On my WIndows cmd, it said "MongoError: command insert requires authentication" I was quite confused at this point because I did follow the video (link below) => How To Install MongoDB In 2 Minutes , and have my mongodb installed. link: kzbin.info/www/bejne/rZTbZJlmmrqcd9k&ab_channel=WebDevSimplified = = = = = = = = = [Cause] = = = = = = = = = 【mongod isn't running】 By just have mongodb installed isn't enough. I should have my "mongod" run as well. So, I follow another video (link below) => How to Install MongoDB on Windows 10 link: kzbin.info/www/bejne/fKiwqIJupb2Zp5I&ab_channel=ProgrammingKnowledge = = = = = = = = = [Problem Solved Steps] = = = = = = = = = Following the 2nd video, here's the outline of that video 1. install mongodb on the host 2. open up cmd and cd to the path including mongod.exe (default path: C:Program Files/MongoDB/Server/4.4(ver. num)/bin/) 3. mongod.exe ====> expected err occur, and the err msg hint us to add folder right under "C:" 4. ADD a folder named "data" 5. Inside C:data/, add a folder named db 6. cd to the path including mongod.exe (see step 2) 7. mongod.exe ====> successfully running At 19:48, after clicking Create Btn, my page finally navigated to localhost://3000/authors Note also: In the future, (if following the default setting), the mogod.exe will be ON automatically when restarting the PC.
@AnnieTaylorChen
@AnnieTaylorChen 5 жыл бұрын
Finished this part today. Took me a while to fix my errors, lol. I do have two questions: 1. I noticed we aren't using path.join, which I usually do. If we need to collaborate with people using different OS, it is better to use this, correct? I use Linux but I think on Windows the path is not the same. 2. So far I've used EJS and Handlebars, which one is better? why? I personally prefer handlebars just because I think is more weird than {{}}. But that's not the valid reason...
@WebDevSimplified
@WebDevSimplified 5 жыл бұрын
1. path.join is definitely better and I should have used that in the places I didn't. I always forget though. 2. It actually really doesn't matter which templating language you use. It is mostly personal preference since they all do the same thing. The only real difference is syntax. I generally use EJS for teaching since it is the closest to HTML so it is the least confusing for people new to templating languages.
@abmilan
@abmilan 2 жыл бұрын
To all those people who are not getting an error message displayed, clear the text field there is a chance there will be a space inside it and it will no longer be counted as empty
@utkarshdhiman9680
@utkarshdhiman9680 4 жыл бұрын
why we used 'locals.errorMessage' what is 'locals'? 23:35
@moss1644
@moss1644 Жыл бұрын
I like you showing the effect of what you are doing side by side in practice. Very clear and easy to understand.
@tangoalpha6013
@tangoalpha6013 3 жыл бұрын
Hello, I have this error at the end of the video when adding a new Author: ReferenceError: Author is not defined at /home/user/myapp/routes/authors.js:24:39 Anyone can help?
@andymcdonald8922
@andymcdonald8922 2 ай бұрын
I know this is 3 years old, but just to help anybody else in the future. Make sure you have the new author route set up correctly as this is where author is defined. If this is done correctly and everything else is ok, it should work //New author Route router.get('/new', (req, res) => { res.render('authors/new', { author: new Author() }) })
@supercoolcat7692
@supercoolcat7692 3 жыл бұрын
The folder and file text sizes are way too small for users watching on mobile devices. Still this is one of the best and easiest to understand Node js courses I’ve ever seen. Thank you very much for this
@rmoshiulhasan007
@rmoshiulhasan007 3 жыл бұрын
When Creating a New author, if the author(name) already exists in the database..... For BEST authors(a different page which includes top 10) I may want to show it on Index Page but I don't want to show it on that page (/bestauthors) page, but instead I want to increment the count of book entries from the same author which already exists and I want to show them like this, their name and no. of entries. How can I do that. Please help. Thanks in advance. Best Authors 1. X (14) 2. Y (9) and so on. I really appreciate for your videos.
@rushikeshkumbhar7735
@rushikeshkumbhar7735 Жыл бұрын
You teach each concept so casually that we start thinking, "ha... it's that easy! we can do it too. " Thank you for the course, it still guides students like me.
@rexparker6011
@rexparker6011 4 жыл бұрын
I was getting an error in the author.js route. I tracked down the error and here's what I found: At 30:00 The author writes on line 9: searchOptions = new RegExp(req.query.name, 'i') and this produces an error on line 12 because the .find(searchOptions) is expecting an object and getting a string like this: /jo/i the solution is to create an object on line 9 like this: searchOptions = { name: RegExp(req.query.name, 'i')} Note: I found the error by passing (err) to catch like this: catch (err) { console.log(err) res.redirect('/') } this error should be passed to the page, but res.redirect('/') doesn't seem to allow passing an error message.
@karansukhija415
@karansukhija415 4 жыл бұрын
That's what he exactly did. searchOptions is an object and he added name property to it. He did it right.
@AddisMultimedia
@AddisMultimedia 4 жыл бұрын
Thank you so so much it works after I made the changes.
@rayhanmahmud6589
@rayhanmahmud6589 3 жыл бұрын
Thank you.
@tanujagarwal5831
@tanujagarwal5831 3 жыл бұрын
at [19:58] when i am submitting empty name field then i am not getting error even though have mentioned the condition required: true in schema but in my batabase empty string is also getting saved. plz help
@peopleyoumustknow1325
@peopleyoumustknow1325 3 жыл бұрын
Did u have solution, I am stuck in this as wel.
@quocdungnguyen615
@quocdungnguyen615 3 жыл бұрын
@@peopleyoumustknow1325 me too
@asemshaat6672
@asemshaat6672 2 жыл бұрын
I'm still having the same issue. Let me know if you solved it plz
@tanujagarwal5831
@tanujagarwal5831 2 жыл бұрын
After few days when i started this again it startee working fine automatically
@rhyno3780
@rhyno3780 4 жыл бұрын
Not sure why this is different for me, but for the try catch statement I had to make sure to pass the exception to catch. So line 25 on authors.js I had } catch (e) { hope this helps if someone has an error.
@WebDevSimplified
@WebDevSimplified 4 жыл бұрын
This is just because you are running an older version of Node.js
@_Greenflag_
@_Greenflag_ 2 жыл бұрын
GOD I had trouble making this Heroku app working instead of launching it with node in the "start" key, I was launching it with nodemon, it never started, always got Heroku application error xD
@furkanzengin7635
@furkanzengin7635 3 жыл бұрын
Hi, when I am trying to submit new authors, it does not get the information and giving me error that TypeError: Cannot read property 'name' of undefined.
@duonghoanghuy8446
@duonghoanghuy8446 3 жыл бұрын
Do you fix it up ? if not, you can try: router.post('/',express.urlencoded({limit: '10mb', extended:false}),(req, res)=>{ res.send(req.body.name) })
@Kk-xk5cb
@Kk-xk5cb 3 жыл бұрын
@@duonghoanghuy8446 wow, what a life saver! thanks so much! do you mind how you debugged it?
@parveenrohilla7523
@parveenrohilla7523 2 жыл бұрын
@@duonghoanghuy8446 it really helps thanks
@mr.poopybutthole3719
@mr.poopybutthole3719 4 жыл бұрын
This is seriously awesome!🔥 A lot to digest in 30 min... Did saw this video for 5-6 time to get all that info😅
@ivelingachev6811
@ivelingachev6811 2 жыл бұрын
When I clicked create when field is empty I didnt get error message and " " value was inserted in my database.If you have same problem add this to your mongoose schema: const authorSchema = new mongoose.Schema({ name: { type:String, required:true, validate: /\S+/ } }) It solved my problem
@persidachita69
@persidachita69 2 жыл бұрын
Thank you very much
@simpleprogrammer5834
@simpleprogrammer5834 4 жыл бұрын
thank ya Kyle for this helpful lesson but I'm handling problem initializing the App on heroku it keeps giving me ' Application Error ' when I Enter new author !!! but on my local server every thing is perfectly great and working |: HELP PLZ!
@ricardotenorio5624
@ricardotenorio5624 4 жыл бұрын
Have you solved it?
@simpleprogrammer5834
@simpleprogrammer5834 4 жыл бұрын
@@ricardotenorio5624 no brother unfortunately no one gave me the solution yet 💔
@ricardotenorio5624
@ricardotenorio5624 4 жыл бұрын
@@simpleprogrammer5834 this is probably an error when connecting to database, in my situation I paste the databse_url value with "" instead of "test"
@simpleprogrammer5834
@simpleprogrammer5834 4 жыл бұрын
@@ricardotenorio5624 did it work?
@ricardotenorio5624
@ricardotenorio5624 4 жыл бұрын
@@simpleprogrammer5834 yep!
@neo9117
@neo9117 10 ай бұрын
I really cant understand how this .ejs works and why its good literally every variable I include in ejs files is undifined and idk why what Im doing wrond?
@pinnerKnight
@pinnerKnight 11 ай бұрын
I like your explanations but you speak so fast, maybe it's just a feeling I have because I'm not an english native speaker.
@umaedu3097
@umaedu3097 11 ай бұрын
could someone help me understand how to make a three different page website according top this model? thank you :)
@omgerplayz
@omgerplayz 5 жыл бұрын
When I try creating a new author on Heroku, it just doesn't respond!
@ricardotenorio5624
@ricardotenorio5624 4 жыл бұрын
Have you fixed that?
@sumukhbhat1641
@sumukhbhat1641 4 жыл бұрын
Same problem!
@MarkBoyd14
@MarkBoyd14 4 жыл бұрын
make sure that you include your password and dbname (I think dbname can be anything but if not just set it to "test") in the DB_URL on Heroku. Make sure you remove the brackets as well.
@stepanfau6480
@stepanfau6480 3 жыл бұрын
Faced similar issue - turned out to be a typo in my DATABASE_URL in heroku->settings->config vars. Try doublechecking that :-) if your local dev environment is working, make sure the URLs are identical.
@shashwathsk6880
@shashwathsk6880 2 жыл бұрын
there is some problem in my heroku , even though i white listed my ip to 0.0.0.0/0 my app is not loading it showing 'application error'
@bhaskarnhuchhepradhan8
@bhaskarnhuchhepradhan8 5 жыл бұрын
If you get stuck trying to run with with the error "Unexpected token {" then add (error) besides the catch so it will be catch (error) { res.render('authors/new', { author: author, errorMessage: "Error creating Author" })
@WebDevSimplified
@WebDevSimplified 5 жыл бұрын
Good find. If you run into this issue it most likely means you are running on an older version of Node.js, since the error section of catch is optional in newer versions.
@bhaskarnhuchhepradhan8
@bhaskarnhuchhepradhan8 5 жыл бұрын
@@WebDevSimplified Oh that does make sense. Thank you for your response. Appreciate the videos!
@hassanayasrah9908
@hassanayasrah9908 2 жыл бұрын
thank you
@Smitty1x
@Smitty1x 2 жыл бұрын
Around the 28:00 mark my terminal stopped responding to npm run devStart and I can't connect to the server anymore
@Mammoth17
@Mammoth17 3 жыл бұрын
is anyone else having trouble getting it to Connected to Mongoose "MongooseServerSelectionError: connect ECONNREFUSED ...."
@JenniferStewart100
@JenniferStewart100 3 жыл бұрын
You may need to look at the last video to see if you missed anything. I know that Mongodb looks different now then when he made this video. When you add the string in Heroku to connect make sure you add the password, but also make sure you delete the portion of the string, and instead add test. It should look like mongodb+srv://user:PASSWORD@cluster0.buw8j.mongodb.net/test?retryWrites=true&w=majority
@stanleylouis1028
@stanleylouis1028 5 жыл бұрын
If you are using prettier with visual studio code, add a .prettierignore file in the root directory with the content *.ejs to keep prettier from formatting ejs (control flow statement) like the if statement in this video.
@WebDevSimplified
@WebDevSimplified 5 жыл бұрын
Great comment. Prettier is super nice.
@rayhanmahmud6589
@rayhanmahmud6589 3 жыл бұрын
Even though I love prettier, it was bothering me when it kept messing with the '.ejs' files. Thank you for this solution.
@davidna7264
@davidna7264 4 жыл бұрын
33:00 i put the ip 0.0.0.0/0 there and still Application error on the heroku server. (with localhost its works)
@suthirakprom
@suthirakprom 4 жыл бұрын
if it doesnt work, you just have to wait for a little bit. It might differ on the speed of your internet connection.
@ricardotenorio5624
@ricardotenorio5624 4 жыл бұрын
Same to me, on my localhost runs, but in heroku I got connection error =/
@psharma4857
@psharma4857 4 жыл бұрын
@@ricardotenorio5624 Do you have a fix for this now? I am still facing the issue and it says Application error.
@armyindo4085
@armyindo4085 4 жыл бұрын
so do i . just have some problem with you
@armyindo4085
@armyindo4085 4 жыл бұрын
i fix my problem
@samsammurphy
@samsammurphy 5 жыл бұрын
To use HTML autocomplete (i.e. Emmet) in an ejs file you will need to install the 'ejs Snippets' extension
@WebDevSimplified
@WebDevSimplified 5 жыл бұрын
Good suggestion. Another thing you can do is go into the settings and tell emmet that .EJS files can use emmet
@samsammurphy
@samsammurphy 5 жыл бұрын
Very cool!
@subratarudra2745
@subratarudra2745 Жыл бұрын
If anyone is facing problem at 20:44, then I would suggest to use "" instead of "" in errorMessage.ejs, this will resolve the error.
@KalpakChakraborty
@KalpakChakraborty Жыл бұрын
what does the local thing do??
@subratarudra2745
@subratarudra2745 Жыл бұрын
@@KalpakChakraborty I have found this on stackoverflow. I don't know the reason in detail. But I think it will use the local errorMessage(i.e errorMessage of local scope).
@UpTballA
@UpTballA 4 жыл бұрын
@Web Dev Simplified I tried to watch this course 4 months ago and it was very difficult and I had to learn Laravel at the time so I stopped at this episode. Now coming back to this after learning a lot of laravel. You really don't waste any time and theres so much impact in every action you make. Pathetic this has 16k views, its a goldmine of information. Thanks a lot man for this course
@WebDevSimplified
@WebDevSimplified 4 жыл бұрын
I'm really glad you are enjoying this course now that you are getting back into it.
@myhanhnguyen5198
@myhanhnguyen5198 2 жыл бұрын
why do you have 2 routers for creating a new author? I dont understand this part (1:10). as i understand, router.post() for creating a new author while router.get('/new',....) for getting an author
@KalpakChakraborty
@KalpakChakraborty Жыл бұрын
get at /new is basically to open the page for adding the new author. post at /new finally adds the author
@clintrodricks1062
@clintrodricks1062 5 жыл бұрын
Great video! I'm getting an error at 28:34 stating authors is not defined. I'm pretty sure everything I've done it exactly as you have done it with the exception of running everything locally. Any ideas?
@WebDevSimplified
@WebDevSimplified 5 жыл бұрын
Check where the error message is coming from and you should be able to trace it back to the issue. If not you can checkout the code linked in the description and compare it to your code
@chaitanyaprakash8470
@chaitanyaprakash8470 5 жыл бұрын
in authors.js remove the ) after authors/index and put it after the closing }
@abdullahihassan8279
@abdullahihassan8279 5 жыл бұрын
@@WebDevSimplified i everything is same as your code but it is still not working
@abdullahihassan8279
@abdullahihassan8279 5 жыл бұрын
@@chaitanyaprakash8470 that would cause a syntax error
@chaitanyaprakash8470
@chaitanyaprakash8470 5 жыл бұрын
@@abdullahihassan8279 give it a shot it worked for me
@stepanfau6480
@stepanfau6480 3 жыл бұрын
Tip: Since express 4.16 you don't need to use body-parser. You can go with native express.urlencoded()
@lmartinezj
@lmartinezj 3 жыл бұрын
for some weird reason I get req.body.name as undefined
@thetester8371
@thetester8371 3 жыл бұрын
@@lmartinezj did you fix it in the end? I am getting this error where it says "name" is not defined. I am pretty sure I do not have any typos.
@lmartinezj
@lmartinezj 3 жыл бұрын
@@thetester8371 hi there, I did fix it, but it had to do with a declaration at the top of the program that required a specific logic... It's not at the top of my head right now, but I can get back to you soon
@lmartinezj
@lmartinezj 3 жыл бұрын
@@thetester8371 Got it, went back on my github and found the code commented app.use(express.urlencoded({ extended: true })) // Has to be implented before app.use('/', indexRouter)
@thetester8371
@thetester8371 3 жыл бұрын
@@lmartinezj Ok, thanks man. I will really appreciate it.
@FaTima-lr8yf
@FaTima-lr8yf 2 жыл бұрын
I keep getting this error "TypeError: db.on is not a function" or "mongoose.Connection.on is not a function", anyone have an idea how to fix it?
@khalvin8
@khalvin8 2 жыл бұрын
Did you download Mongoose? Check out his video on installing Mongoose. Make sure you assign the PATH correctly. The latest version of Mongoose has a new shell. MongoSH. I had issues getting the service to run as a local service.
@babar-khan
@babar-khan 4 жыл бұрын
are you gonna make any multi auth registration and login series, please?
@basketberoende
@basketberoende 4 жыл бұрын
Hello! I'm getting a "TypeError: Cannot read property 'fname' of undefined" when I am trying to create a new (member in my project). I have declared body-parser and required it. I have also double-checked the name of the form and the method. I know the rout is working because when I do res.send('Hello world'), it works, But as soon as I try res.send(req.body.fname), it does not work. If I console log the req.body it says undefined. Do you have any idea where the error might be?
@basketberoende
@basketberoende 4 жыл бұрын
If any one run in to the sam problem, i found the solution, you have to implement the bodyparser to the server before the you define the routes. The order matters!
@pratikshpatel5227
@pratikshpatel5227 4 жыл бұрын
@@basketberoende can you share your code? i have the same issue
@basketberoende
@basketberoende 4 жыл бұрын
@@pratikshpatel5227 nah bro, i have deleted the project! but all i did was require('body-parser') and the importend part is to do app.use('your body parser') before the routes
@tejasjoshi1907
@tejasjoshi1907 4 жыл бұрын
@@basketberoende thanks for this awesome solution !
@jamesmassa1999
@jamesmassa1999 2 жыл бұрын
@@basketberoende Thank you... 😁
@pratikshpatel5227
@pratikshpatel5227 4 жыл бұрын
How do you code wise implement the bodyparser to the server before the you define the routes ?
@deathvall3y
@deathvall3y 5 жыл бұрын
authors are being saved to database (local) . I am adding author but none is showing up in '/authors'
@emashno5
@emashno5 4 жыл бұрын
Im having the same problem on that one too...
@pratikshpatel5227
@pratikshpatel5227 4 жыл бұрын
Problem: TypeError Cannot read property 'name' of undefined Solution: -----------------------------authors.js file----------------- //creating a variable to store the body-parser library files var bodyParser = require('body-parser'); // parse urlencoded request bodies into req.body var urlencodedParser = bodyParser.urlencoded({ extended: false }); //Create Author Route [Post is used for creation] router.post('/',urlencodedParser, (req, res) => { res.send(req.body.name) })
@ericalexander3816
@ericalexander3816 4 жыл бұрын
TypeError: Author is not a constructor at \Fullstack\backend outes\authors.js:13:41 anyway to fix this????
@viperxiv5835
@viperxiv5835 4 жыл бұрын
did you find a solution?
@ericalexander3816
@ericalexander3816 4 жыл бұрын
@@viperxiv5835 No, I moved on.
@viperxiv5835
@viperxiv5835 4 жыл бұрын
word
@viperxiv5835
@viperxiv5835 4 жыл бұрын
Not sure if you're still interested but I think I figured it out, my node was out of date. Updating it didn't fix it right away but I had to restart my machine and when I came back it was working, so guessing either VS Code or OSX needed to be restarted to get the updated node version working.
@stepanroznik7545
@stepanroznik7545 4 жыл бұрын
@@viperxiv5835 I solved this problem differently. It turned out I made a typo in the models/author.js file. I missed the "s" in "module.exports"
@lenniemoses8003
@lenniemoses8003 Жыл бұрын
Anyone else getting "[nodemon] app crashed - waiting for file changes before starting..." in the terminal when running the server? The server actually runs when I start it but then after a few seconds it'll crash with this message.
@houssemkhi5036
@houssemkhi5036 4 жыл бұрын
minut 28,46 ReferenceError: /home/houssem/BUG/views/index.ejs:8 6| 7| >> 8| { %> 9| 10| authors is not defined
@krishnamuraree2662
@krishnamuraree2662 2 жыл бұрын
did u found out?
@Marwan-
@Marwan- 2 жыл бұрын
First of all ThnQ Kyle for this course! If you are having issues with the search not working I found the following to work for me: The Search was just showing me all of the names, and not actually filtering for the search. this is what I did to fix it. Replaced: const authors = await Author.find( { searchOptions } ); To this 'remove curly braces' : const authors = await Author.find( searchOptions ); Most probably the syntax changed from the time this video was made.
@shuklavishwam
@shuklavishwam Жыл бұрын
Hello, Thanks for the video. I tried creating some routes using express but I can't get a way around on ec2. It fails with a Error called Cannot Get /routeName. Is there any workaround to get this done?
@houssemkhi5036
@houssemkhi5036 4 жыл бұрын
minut 28,46 ReferenceError: /home/houssem/BUG/views/index.ejs:8 6| 7| >> 8| { %> 9| 10|
@Deep-ni4xl
@Deep-ni4xl 2 жыл бұрын
9:37 what was the purpose of giving variable { author: new Author() } ,while we creating author on //create author Route, app work fine and creating new auther without above variable.
@ast453000
@ast453000 3 жыл бұрын
I'm not sure why he puts the author.name as the value of the input field in _form_fields.ejs. It seems to me the author.name doesn't have a value and it will just be overwritten by anything the user inputs. I do wish he would slow down when he talks too. He seems to talk even faster when he's explaining the most complex parts.
@tag_of_frank
@tag_of_frank 2 жыл бұрын
Is there a mongoose model style library for MySql? Up until now I have been writing all my queries and creating tables with raw SQL code the mongoose library is so great.
@jacobthedev4979
@jacobthedev4979 2 жыл бұрын
In "layout.ejs" how does know what to render, yet for the header we have to use "include('...')" in order for it to use the proper header.
@shawonsheikh163
@shawonsheikh163 2 жыл бұрын
I keep getting the error Could not find the include file "_form_fields" when i try to click on add author and add books anyone know why?
@sounymalivanh889
@sounymalivanh889 4 жыл бұрын
errorMessage is not defined how can i solve this error?
@WebDevSimplified
@WebDevSimplified 4 жыл бұрын
I answer this later in the video or in the next video.
@surfinbird71
@surfinbird71 4 жыл бұрын
At 22:53
@hassanayasrah9908
@hassanayasrah9908 2 жыл бұрын
if the else part in creating new Author not warking even thow you're entering empty value, it might be because the browser add defult white space to the input
@amirabasahmadnia4683
@amirabasahmadnia4683 4 жыл бұрын
Great channel. thank you
@KromedesShooter
@KromedesShooter 2 жыл бұрын
I can't figure out how to implement react in a proyect like this? I don't want it to be a SPA. If someone know a tuto for this please link it!
@christopherjenkins2433
@christopherjenkins2433 3 жыл бұрын
Keep getting stuck at the authors page. Not sure if it created an author to store into authorSchema, because the ejs file keeps saying authors.forEach is not defined.
@JayRGabz
@JayRGabz 5 жыл бұрын
I'm creating this project right now... so excited to finish this. :)
@WebDevSimplified
@WebDevSimplified 5 жыл бұрын
I hope you enjoy it!
@haarishkhan2158
@haarishkhan2158 Жыл бұрын
how are you able to get author.name and searchOptions.name in ejs file without importing. i am confuse on this can someone explain?
@MonsterFishKeepersPH
@MonsterFishKeepersPH 2 жыл бұрын
the error message just don't seem to pop up when I click the create button without anything as input! please help me!!!!!
@tag_of_frank
@tag_of_frank 2 жыл бұрын
With async version how can you get the error out of author.save? Doesn't it make things hard to debug without the actual error?
@omrankhoja319
@omrankhoja319 3 жыл бұрын
hey man this is a great series, really solid stuff thank you! One thing that's bugging me is even with the extension my .ejs tags are white rather than gray like the html tags. Anyway I can fix that? Can't seem to find anything online about it.
@WiktorJurek
@WiktorJurek 3 жыл бұрын
This is amazing! Have you got a video about the basics of MVC/routing? I feel I need a bit of background regarding the principles behind the decisions you're making.
@o1techacademy
@o1techacademy 2 жыл бұрын
This tutorial has boost my confidence as a full stack developer. Thank you very much Kyle
@fluffydoggo
@fluffydoggo 4 жыл бұрын
Wow now my express server REALLY needs updating. The code you are making is wayyy more organized. I have all requests in a single index.js file lol. Thanks for the tutorials though. I'm not new, but it's interesting to learn new stuff. Keep up the good work 👍
@kavithachellasamy2393
@kavithachellasamy2393 3 жыл бұрын
Thanks for the Video Kyle and ur Effort for making and clearly explaining this.
@h2nrlc
@h2nrlc Жыл бұрын
This teecher is crazy free
@peopleyoumustknow1325
@peopleyoumustknow1325 3 жыл бұрын
I am stucked in create Author, when I type it just gave me the page All Authors
Books Index/Create/New Routes - Node.js/Express/MongoDB Course #3
49:31
Web Dev Simplified
Рет қаралды 76 М.
Project Setup - Node.js/Express/MongoDB Course #1
23:29
Web Dev Simplified
Рет қаралды 283 М.
Стойкость Фёдора поразила всех!
00:58
МИНУС БАЛЛ
Рет қаралды 3,6 МЛН
How To Get Married:   #short
00:22
Jin and Hattie
Рет қаралды 22 МЛН
pumpkins #shorts
00:39
Mr DegrEE
Рет қаралды 14 МЛН
MongoDB Crash Course
29:59
Web Dev Simplified
Рет қаралды 689 М.
Will Deno 2.0 Replace Node.js?
12:35
Web Dev Simplified
Рет қаралды 59 М.
Laravel vs Rails for Javascript developers
19:50
Sam Lewis
Рет қаралды 2,7 М.
The secret to mastering CSS layouts
17:11
Kevin Powell
Рет қаралды 283 М.
MongoDB Tutorial For Beginners #19 - Creating Indexes in MongoDB
5:39
Learn useRef in 11 Minutes
10:20
Web Dev Simplified
Рет қаралды 640 М.
Authors Show/Edit/Update/Delete Routes - Node.js/Express/MongoDB Course #5
30:56
I built the same app 10 times // Which JS Framework is best?
21:58
Fireship
Рет қаралды 2,5 МЛН
Learn Express JS In 35 Minutes
36:03
Web Dev Simplified
Рет қаралды 816 М.