My previous video in this series had a corrupted clip in the middle, so I had to re-render and re-upload the video.
@maxiequa5675 жыл бұрын
for anyone watching you might have missed this change : const imageMimeTypes = ['image/jpeg', 'image/png', 'image/gif'] ... 'images' should be 'image' which will correct "error creating book" - had me baffled for a while :\
@dnpshuser4 жыл бұрын
@@maxiequa567 After 4 hours of debugging, saw your comment and succeeded to fix the bug. Thanks..... a lot...
@ezeargen4 жыл бұрын
@@maxiequa567 const imageMimeTypes = ['image/jpeg', 'image/png', 'image/gif'] and still getting Error
@vyshnaviyoj88024 жыл бұрын
you might have put fileName instead of filename in req.file.filename in routes->books.js
@sachinbhutani81774 жыл бұрын
@@maxiequa567 thank you so much bro , spend 3 hours on this error
@stephentrainor4480 Жыл бұрын
I have been coding for only the past 6 months or so and find this extremely advanced. There are so many new concepts being introduced to me that it is a bit overwhelming. Hopefully in time I can wrap my head around them. My plan is to use this project as a springboard to create my own blog (with my own server) to document the journey of me and my wife converting our camper van!
4 жыл бұрын
In the case you are getting an error creating a book at around 29:00 because it cannot read your book cover, change the imageMimeTypes const so "images/jpeg" becomes "image/jpeg" and so on with the other types of files
@shahnawazshaikh69604 жыл бұрын
still getting error
@srinathravichandran87964 жыл бұрын
@@shahnawazshaikh6960 check if the elements in book ejs file contains the correct name !
@giftbrightson48263 жыл бұрын
thankyou this solved the error
@daveperry71793 жыл бұрын
Legend mate
@tobiasleitner79403 жыл бұрын
Thank you dude. After 1 hour of researching i went to the comments and this was the solution hahaha
@Cyrusdvarus4 жыл бұрын
Thank you so much for doing this. I literally spent like 2 hours debugging just realizing that I misspelled "value" in the _form_fields.ejs file. I really took the time to read through every single file to understand the material!
@DarkCloud73 жыл бұрын
Writing this on 07.01.2021: In the file routes/book.js I had to change the line: >const imageMimeTypes = ['images/jpeg', 'images/png', 'images/gif'] to: >const imageMimeTypes = ['image/jpeg', 'image/png', 'image/gif'] In other words, replace "images" with "image".
@never-a-stain69863 жыл бұрын
good save
@QuangTran-nz9ev2 жыл бұрын
Thank you this solve my problem when I have req.file is undefined
@casey53903 жыл бұрын
For anyone having the upload book error, and your mime types are correct (image/jpeg, not images), check that in your const upload = multer({... section in routes/books.js, the file.mimetype has a lowercase T. I had callback(null, imageMimeTypes.includes(file.mimeType)), with a capital T, and couldn’t figure it out for like 2 days and gave up, but just figured it out now
@shiqihe19943 жыл бұрын
I have the same problem as you... You safe my life, thank you!
@lindam98483 жыл бұрын
huge thanks!!!
@austincoffee64843 жыл бұрын
This was my exact issue! Thank you so so much!!
@nayyyhaa3 жыл бұрын
Made the same, images image error! haha, thankyou so much!!!
@thezionjohnson35902 жыл бұрын
thanks man (file.mimetype) worked for me
@stephentrainor4480 Жыл бұрын
For anyone having errors creating a book. Check that the names in the bookSchema in "book.js" match all of the names that you are calling in your route. I had specified "coverImage" rather than "coverImageName" in mine. The way I debugged was by copy and pasting each of the files from Kyle's git into mine to see if this resolved the error. Once I isolated the page, I was able to go line by line and find the culprit. Hope that helps.
@xdiegors Жыл бұрын
Dude you saved me! Thanks!
@bejerky5 жыл бұрын
First of all, your videos are are one of the best I have seen in this field. You really know your sh%$! :) And your teaching method is really thorough and clear. Thanks and keep up the good stuff! p.s. If someone runs into the same issue as I had with uploading the cover image. My fix was to use 'image' instead of 'images' for all array items in the "imageMimeTypes" variable. So instead of 'images/jpeg' , use 'image/jpeg' .
@WebDevSimplified5 жыл бұрын
Thank you! I'm really glad my videos are helpful.
@MuhammadArif0055 жыл бұрын
Worked for me! Thanks bro
@exnihilo12275 жыл бұрын
Thanks
@lorikaliu20275 жыл бұрын
Thank you
@kec57544 жыл бұрын
Bjarki Guðmundsson thank you! It works
@Al_Gonzo4 жыл бұрын
Hands down the best channel. Ive looked at so many Node js videos that try to connect to a database but your videos are by far the most informative and I also learn a lot even tho I dont have that much experience in back-end.
@rabitebibi4 жыл бұрын
You are the best of the best bro. I must admit that your way of teaching and explaining is so clean and professional. Good bless you. Your videos are so short but have a deep and broad explanation.
@vladimirdoktorov15115 жыл бұрын
So far my favourite course, it is amazing to see how everything works and I can finally see the power of javascript. It is funny to realise that I spent all day watching 30 minutes video and fixing my typos haha. Amazing content and channel, I remember times when Joshua Flake had 8k subs and I knew he will be big one day, I think you will get to 100k very soon. Cheers buddy
@WebDevSimplified5 жыл бұрын
Thank you so much. I am really glad you are enjoying the course. It took a long time for me to finish this course, and I am glad to see it was worth the effort. I'll see you at 100k ;P
@vladimirdoktorov15114 жыл бұрын
@@WebDevSimplified here we go, you have over 100k subscribers, glad to see your channel growing, by the way I have got my first dev job and guess what I use, MVC :) still confused tho hopefully see some c# content from you lol
@enjili60624 жыл бұрын
@@vladimirdoktorov1511 Now he is 317k, grows really fast
@_tgwilson_2 жыл бұрын
@@WebDevSimplified 100k * 10 and you deserve it : )
@humaneone5581 Жыл бұрын
@@enjili6062 1.2 millions now
@rayhanmahmud65893 жыл бұрын
If anybody encounters an issue and can't solve it on their own, I suggest downloading the codes from Kyle's GitHub repository and match them with your own code. That way you can find out if you've missed something while writing your code. It's a bit of a tedious process, but I found that it helps.
@rayhanmahmud65893 жыл бұрын
@@drbulltrader9107 Kyle's code for this video can be found here: github.com/WebDevSimplified/Mybrary/tree/v1.2 You can also find this link in the description of this video.
@andreweinhorn4 жыл бұрын
I'd recommend watching this on 0.85x speed. Awesome tutorial!
@rubenverster2503 жыл бұрын
hah. Noob. Only at 2X XP
@incognito83362 жыл бұрын
29:30 for anyone getting The "path" argument must be of type string. Received undefined. In book.js, module.exports.coverImageBasePath=... should be below module.exports=...
@joshuajaydan2 жыл бұрын
getting the same. Haven't found a fix yet.
@joshuajaydan2 жыл бұрын
Found a fix. models/book.js is missing a function. bookSchema.virtual('coverImagePath').get(function() { if (this.coverImageName != null) { return path.join('/', coverImageBasePath, this.coverImageName) } })
@strikerron22524 жыл бұрын
yo this is very advanced it will take a lot of time to completely learn this
@andreweinhorn4 жыл бұрын
agreed. but as with all learning - code in particular - i think the metaphor of walking into a dark room applies. you sort of bumble around, bumping into things, but after a while, you get used to where they are and soon enough - with a bit of persistence - you can operate quite fluently in the space. good luck!
@strikerron22524 жыл бұрын
@@andreweinhorn Thank You
@chrisbenjamin30723 жыл бұрын
Kyle, Awesome video!! In order to solve issues I had creating book I had to do the following after reading comments and comparing code. 1. Rename imageMimeTypes to singular (const imageMimeTypes = ['image/jpeg', 'image/png', 'image/gif']) 2. Found that I put enctype="multipart/form-data" in the Author's new.ejs file instead of the Books new.ejs file 3. In the catch of router.post I didn't realize the renderNewPage(res, book, true) was slightly different when it was copy/pasted. I still have renderNewPage(res, new Book(), true)
@miki_w2 жыл бұрын
Thank You! I made mistake no. 2 and couldn't find it
@albertoazinar12094 жыл бұрын
this channel is really here to simplify web development. Thank you Kyle
@codingjim37344 жыл бұрын
For those who have the error : MulterError: Unexpected field make sure you have the name of the input field same as multer's upload.single('name'). In my case, I have put the name for 'Cover' in forms and 'cover' in upload.single(), and it was making this error.
@enjili60624 жыл бұрын
Do you know why does it have to be 'cover'? I tried different names such as 'thecover", changed the name in form as well, but it doesn't work
@maniac14412 жыл бұрын
How did you fix this
@keshavgautam53 жыл бұрын
For those getting error while creating book at 29:00 ... I was missing some lines of code in model/book.js file try adding this before module.exports. bookSchema.virtual('coverImagePath').get(function() { if (this.coverImageName != null) { return path.join('/', coverImageBasePath, this.coverImageName) } })
@omrankhoja3193 жыл бұрын
Thanks!!! I was stuck on this part for like an hour.
@maniac14412 жыл бұрын
Done.. but still got error
@HiJustEli2 жыл бұрын
Thank you so much, this was my problem. Kept getting console errors saying "Couldn't find file localhost:3000/public/uploads/bookCovers/". Changing 'public' to '/' in path.join() was the solution!
@ahmedroberts48832 жыл бұрын
I Love this Series! WhooHoo!
@rickeyupadhyay68984 жыл бұрын
Brother you are typing speed and your explanation is on another level ! Your code is so clean how much experience do you have? What is your age? Want to know these things, you look so young, are you graduated because the knowledge you provide we can't be able to get from a degree. Please reply 🙏
@WebDevSimplified4 жыл бұрын
I have about 5 years experience and I graduated 3 years ago. I am currently 25.
@rickeyupadhyay68984 жыл бұрын
@@WebDevSimplified It's great thanks for the reply, lots of love from India 🇮🇳
@jiwonjang59292 жыл бұрын
Please help. For uploading file, I have succeeded but the file is not showing in folder(public/uploads/bookCovers). Also I fixed 'images/jpeg -> image/jpeg" issue aleady. It might be other problem. Thanks a lot for any advising.
@itss_juno2 жыл бұрын
Not sure if you still want the answer or not but I was having the same issue. At 24:24 he edits out a clip and you can see new code for a split second. This is also where you see he changes images to image. To fix this issue on the upload variable in books.js make sure the file filter is as follows fileFilter: (req, file, callback) => { callback(null, imageMimeTypes.includes(file.mimetype)) }
@gabrielnardes97413 жыл бұрын
If you are stuck around 29:00, with "Error creating book", a possible solution: My problem was the space between %> and " in views/books/_form_fields.ejs,. Check if you have: value=" " // WRONG instead of value="" // CORRECT Putting console.log in router.post('/', upload.single('cover')... catch (err) { console.log(err); renderNewPage(res, book, true); } Sometimes gave me a: Error: Argument passed in must be a single String of 12 bytes or a string of 24 hex characte Or: Error: Argument passed in must be a single String x characters. Thanks to @Михаил Новиков.
@tamlongnguyen66042 жыл бұрын
thank you, i was stuck just like you said!!! I fixed it, thanks a lot 😇😅🙇
@jccorman58482 жыл бұрын
I love you @Gabriel Nardes and @Михаил Новиков 😂
@razimoosa70282 жыл бұрын
Thankyou this solved my problem. I was stuck at it for a long time. If you or anyone else reading this comment would tell me why trimming the space between %> and " solved the problem I would appreciate it. I'm a beginner
@efisirify2 жыл бұрын
Greate FS server side rendering course! Thank you so much Kyle. Since the popular stack is building REST in the back and consuming it on the front with front end framework such as react, do you plan posting FS playlist for that?
@IncredibleGilgitBaltistan Жыл бұрын
Those who are having an error 'Error Creating Book' at 29:00. Solved using two errors. 1. change the imageMimeTypes const so "images/jpeg" becomes "image/jpeg", change other type too. 2. Add this line before module.exports in books.js model. bookSchema.virtual('coverImagePath').get(function () { if (this.coverImageName != null) { return path.join('/', coverImageBasePath, this.coverImageName) } })
@doubidouah3 жыл бұрын
Thanks for the great tutorials. I have an error after long search I found out that I had to TRIM the req.body.author "author: req.body.author.trim()," as a space was added to the end of the variable and kept getting back the following error message: _message whole saving to collection/Database: 'Book validation failed' " reason: Error: Argument passed in must be a single String of 12 bytes or a string of 24 hex characters" Hopefully it will save someone else some time. Keep the good work and hopefully we get more from you.
@ИльясУмурбеков3 жыл бұрын
Do you know why this happens?
@michaelthomas42923 жыл бұрын
after the closing ejs tags for that line make sure there isn't. space between the closing tag and the closing html tag. if there is, this will translate into the req.body.author and mongodb will not recognize it since it looks for an exact number of characters.
@amrrhaniff2 жыл бұрын
oh my, I've been stuck on this problem for a while and found the solution here. Big thanks mate
@marcosfabianchongmegchun76682 жыл бұрын
thanks, I was getting that error and the solution worked for me :)
@persidachita692 жыл бұрын
You just saved me , thanks.😊
@MrSlapeS3 жыл бұрын
Random idea for saving images (have not tried) - maybe images could be uploaded to for example Flickr and use links to show images. Flickr has an API
@noumanahmad23133 жыл бұрын
same as I was thinking
@danialhasan53954 жыл бұрын
you deserve the wealth that comes your way. thanks for the value wds
@boualihoussem95494 жыл бұрын
hello , every one if some one sees this error tite: MongooseError [ValidatorError]: Path `tite` is required. one of the solution is to comment required : true on the propertie tite , and make validation on the side of the Front ( adding the required on the input field)
@gabriel_wedman2 жыл бұрын
omfg thank you so much!
@antonimdara30333 жыл бұрын
Love the series, full of explains but some of the time its choppy like 24:25 its so sudden having a chance so i often missed steps
@ProgramiranjeDotCo4 жыл бұрын
you do not need to use if (req.query.title != null && req.query.title != '') just use if (req.query.title) i noticed that you are using that quite often
@michaelthomas42923 жыл бұрын
You can also use ES6 short hand for objects, ie: { author: author} -> {author}
@glensrb47235 жыл бұрын
I really like your videoes. I use handlebars and will try to convert your code to my usage. I also liked your video with filepond. Didn't get it working on first try but i really liked it. Keep up the good content, subbed right away! :)
@WebDevSimplified5 жыл бұрын
Hopefully it shouldn't be too hard to convert over. Good luck.
@glensrb47235 жыл бұрын
@@WebDevSimplified I guess it shouldn't. I've just started with web dev and learning JS and all its wonders. I loved the mongoose.virtual in the mongoose model. It really helped with some date formatting I had problems with. I do however use model.save().then() in my code. Do you think this will cause problems with filepond? Do I need to change my code to async/await?
@WebDevSimplified5 жыл бұрын
Async await is exactly the same as using .then so that shouldn't cause a problem. They are just different ways to write the same thing.
@glensrb47235 жыл бұрын
@@WebDevSimplified I thought so but I had to ask. Thanks for your answers, can't wait for next video :) Love your vids, even though it's a little fast paced as I'm not very skilled yet. But you explain very well so I understand most of it :)
@AbhishekKumar-mq1tt5 жыл бұрын
Thank u for this awesome video and series
@WebDevSimplified5 жыл бұрын
You're welcome!
@CuongNguyen-nu3pn4 жыл бұрын
Hello, i got trouble at 29:46. I fill all the fields of book but i'm still get the error message and can not add book into db. Can u find out the bugs?
@narenkulkarni114 жыл бұрын
What's your error? Trace log please
@SR-we1vl4 жыл бұрын
Thank you Kyle! I m so happy to do it myself!
@sakshiupadhyay32843 жыл бұрын
i am not getting may images in public/uploads/bookCovers or anywhere else can any help please
@giorgiobrugnone6879 Жыл бұрын
Great video tnx. What about query by Author? I can't find any example how to query on table linked by mongoose.Schema.Types.ObjectId. Thank you for any suggestion
@JayRGabz5 жыл бұрын
Hi when I console.log my book variable it was null even though i already uploaded a file... it is always null ..
@JayRGabz5 жыл бұрын
fortunately I found out what was wrong... it was the imageMimeTypes.. mine was images/jpeg , images/png ... it should have been.. image/jpeg, image/png
@indigosay4 жыл бұрын
@@JayRGabz you helped me a lot. God bless you!
@indrarahmanto80264 жыл бұрын
thx Jay-R, its work
4 жыл бұрын
@@JayRGabz That saved me, thank you so much!
@abmilan2 жыл бұрын
@ 13:00 page is being redirected to /books instead of /books/new been trying around this problem for many hours
@stepanfau64803 жыл бұрын
30:05 when you demonstrate that error, you get redirected from /books/new to just /books , but the form stays there. How is that possible?
@sauravkumarsonu8293 жыл бұрын
I am getting an error at 29:45, I am filling everything but I am getting error creating book, can you plaese help me with this.
@ethanmichael19463 жыл бұрын
@@sauravkumarsonu829 did you get help?
@elbezz3 жыл бұрын
@@sauravkumarsonu829
@stephentrainor44802 жыл бұрын
Thanks for this course Kyle it's amazing. I don't quite understand why we are using and how that results in the current selection. I know that this is a way for having all authors display as options, but shouldn't all author.id's match all book.author's as those are id's also?
@cierre29552 жыл бұрын
44:26 sorting by dates before and dates after
@okomi5 жыл бұрын
The properties values and label for the select didnt worked for me. I had to use: Any idea why? PS: You tutorial is great and you have a vocations for teaching. Thank you.
@omkar.gaikwad3 жыл бұрын
what you did to resolve that? I'm aslo having same problem :/
@Kk-xk5cb3 жыл бұрын
@@omkar.gaikwad I got stuck at this problem, have you figured it out?
@omkar.gaikwad3 жыл бұрын
@@Kk-xk5cb yes I did, my mistake was I altered the instances of the db model.
@petercullen58895 жыл бұрын
Hey, so i'm having an issue with my cover images just showing up as blank boxes. The images are being created from the correct file path : \uploads\bookcovers\3534ef1c56020c3fa5d0307e5da4d403 For all intents and purposes, the images are physically there. They're just a solid white box. Its like the image hasn't rendered properly from the file. I tried using different images to see if that was the issue but no luck. Thank you for making series like these, I really enjoy watching them. You're so easy to follow and understand.
@WebDevSimplified5 жыл бұрын
Hi Peter. I am not sure exactly what is causing your issue. It sounds like possibly the path to the file that you are rendering in the browser is not right. When you open up your dev tools in your browser and check the console do you see any errors?
@petercullen58895 жыл бұрын
@@WebDevSimplified , Thanks for the quick response! This is what the path looks like and there is nothing currently in the console: imgur.com/a/ZO1ENNT . I'm not sure if it something weird on my computer thats doing it, so ill finish the course and upload it to Heroku to see if that changes anything.
@henrydev61025 жыл бұрын
Could you please add add :app.use(express.static('public')) and try it again?
@WebDevSimplified5 жыл бұрын
I am so sorry it took me so long to reply to your comment. It got marked as spam because of the link and I never got notified. The problem is that imgur links are actually links to an HTML page not an image file. You need to get the raw image link of the imgur to actually use it in the app. The best way to do that is to click the share button on the image and you should find a link in there that has a .jpg or .png ending. That will be the link you want.
@petercullen58895 жыл бұрын
Ah ok, that makes sense. Sorry my bad. Here they are again: i.imgur.com/mj0Tq6o.jpg i.imgur.com/rf4ruFd.jpg hope this works.
@gscc27704 жыл бұрын
37:33 why is '/' already pointing towards the public folder when you're in the models folder?
@viniciusmaciel79464 жыл бұрын
also wanted to know
@viniciusmaciel79464 жыл бұрын
i think i got it. He used app.use(express.static('public')). From now on, everytime he set a path starting with /, the path start at the public folder. My main folder is SRC, and there is a APP folder inside, so my program was app.use(express.static('src/app/public')). As i was using a prefix Static app.use(''/static', express.static('src/app/public')) it took a while to understand
@sierramikekilo69253 жыл бұрын
@@viniciusmaciel7946 I still don't get it. Why path.join('/') points to public folder in the models folder, but not in the routes? He uses const uploadPath = path.join('public', Book.coverImageBasePath) in the books.js file inside the routes folder
@sierramikekilo69253 жыл бұрын
Ok, I watched another video and now I get it. When we create the path in the modules foldes, we are doing this so we can send it to the client in the src property of the img tag in the html: So we are creating a path for the browser to search. When we use app.use(express.static('public')), we are telling the browser that whenever it has to search for a static file, like an image, the root folder is "public". But that is only for browser requests, not for our internal use. When we are setting the path in the route, we are doing it the other way around, we are storing the file in the server.
@usmanmughal59164 жыл бұрын
Getting this error when i try to Create a Book: UnhandledPromiseRejectionWarning: ValidationError: Book validation failed: coverImageName: Path `coverImageName` is required., pageCount: Path `pageCount` is required., publishDate: Path `publishDate` is required.
@mys80913 жыл бұрын
same. Have you find a solution?
@usmanmughal59163 жыл бұрын
@@mys8091 No 1 droped this project long ago
@joshuajaydan2 жыл бұрын
If you get the Path `title` is required error, you might not be waiting for the results of the const newBook = book.save(). Instead change it to const newBook = await book.save()
@LieberLois5 жыл бұрын
Around 19:15 ... why did we create a Book-Object in the new book get route, when we create another one in the create book post route anyways?
@WebDevSimplified5 жыл бұрын
This is because we use the book object in the form view and need to have a book object set.
@farhan_24675 жыл бұрын
why i can't upload the image, and why filename of the image is null ? please response @Web Dev Simplified...
@WebDevSimplified5 жыл бұрын
You may need to change your mime_type section to be "image/jpeg" instead of "images/jpeg"
@farhan_24675 жыл бұрын
@@WebDevSimplified thanks a lot, it' work now
@ShivamSingh-kn3gz3 жыл бұрын
@@WebDevSimplified thanks a billion, I was literally confused like why was even that not working, but thank god I went to the comment section thoroughly. Your tutorials are really awesome, and the best part is, you made every complex thing go so free, thanks again, Love from India
@primalvision16205 жыл бұрын
Hi there, loving the work. Just a quick question, how come you use !=, == instead of !== or ===? I was told this was bad practice in JS and was severely frowned upon during my coding bootcamp. Thank you again for all the work you put out!
@WebDevSimplified5 жыл бұрын
I generally only use double equals when comparing null since it will match null and undefined which I usually prefer. Sometimes I also just forget and use double equals since I am used to it from other languages.
@stanleyluong3 жыл бұрын
at 24:23 it says const imageMimeTypes = ['images/jpeg','images/png','images/gif'] then at 24:24 because of bad editing it magically turns into const imageMimeTypes = ['image/jpeg','image/png','images/gif'] without any instruction or comment from instructor. Took hours to debug this Notice that at first all 3 are plural images then first 2 become singular.
@satyaviswapavanranga59153 жыл бұрын
at13:00, when I hit on localhost:3000/books/new it sends me to localhost:3000/books/
@k.ganesan32444 жыл бұрын
Great Video thanks for sharing
@universalworthy21692 жыл бұрын
The specified value "2022-11-20 " does not conform to the required format, "yyyy-MM-dd": I got this error. I'm wondering why I got a space after the date?
@benedictestrada27744 жыл бұрын
can you help me with this error please Connected to Mongoose (node:9412) UnhandledPromiseRejectionWarning: ValidationError: Book validation failed: publishDate: Cast to Date failed for value "Invalid Date" at path "publishDate", title: Path `title` is required., coverImageName: Path `coverImageName` is required. cant save to public/uploads, please help ty so much!! more power
@houssemkhi50364 жыл бұрын
is the problem still occuring ?
@rickeyupadhyay68984 жыл бұрын
@@houssemkhi5036 yes bro same thing happening with me
@salmansyahbani29124 жыл бұрын
I have the same problems but i only at "coverImageName". Try to change coverImageName to cover in the create new book route, and check in the book scema the name is "cover"
@nitinjoshi72313 жыл бұрын
able to solve error at 29:00 , inside your router.post method , inside book object try changing "coverImageBasePath: fileName", to "coverImageName: fileName", the reason being, in our book.js model we have below mentioned code: bookSchema.virtual("coverImagePath").get(function () { if (this.coverImageName != null) { return path.join("/", coverImageBasePath, this.coverImageName); } }); here we have defined "this.coverImageName" and not "this.coverImageBasePath"
@dangluong11755 жыл бұрын
I love your video. Can you make a debug video for Node in VS Code? Thank you!
@WebDevSimplified5 жыл бұрын
That is a good idea. I will add that to my list.
@megahadroncollider5 жыл бұрын
Excellent tutorial, like many of your previous ones. A bit off topic perhaps, but would you mind doing a series on adonis.js someday? I'm yet to find a good one that coherently explains building a simple app from start to finish, and I keep bumping into walls. Either way, thanks for putting out top notch content -- much appreciated!
@WebDevSimplified5 жыл бұрын
That framework seems really interesting. I have never heard of it but I definitely want to check it out now.
@antran16862 жыл бұрын
I’m watching this video really late but these videos are great! I had a question about searching @41:33. From my understanding, you are getting from the database all of the books and storing into into the variable query then using regexes to filter it and then displaying the query. Am I right about this and if not can someone explain it? If so, how come you don’t use the mongoose .find method and pass in the params and display what that returns. On second thought I realize that bc ur using regex with -i flag you want to find “kyle” even if “le” is passed in but for my case specifically if I wanted to find someone by id in my mongoose database should I use the .find method instead? It has been giving me trouble bc when I use the find method and store it into a variable and try to get it’s values it always return undefined. For example if I say const user = Users.find({email: req.body.email}) Where Users is the mongoose scheme I imported it will give me undefined when I try to say const email = user.email
@guandark2504 ай бұрын
Hello, i wanted to know how could i make so you can upload multiple files of different types, for example, you could upload the cover, the back and a pdf of the book, love your videos!
@agnieszkalewandowska98964 жыл бұрын
Thank you for another lesson :)
@yongkin53892 жыл бұрын
Hello, I wanna ask if I want to upload files instead of image cover, how should I do?
@daxcor4 жыл бұрын
This series is one of the best I found. Thank you. However I am trying to figure out the difference between put and patch. You mentioned it, but you only implemented one of them and not both and you didn't say why or elaborate. What I understand is PUT (replace all content) PATCH only replace the elements that changed. However how would you know what elements have changed? I am a little lost here and would love some clarification.
@raipeter4 жыл бұрын
I'm getting error even if I put the values in books at 29:45, so I copied the code from the githib, but it still shows same error. Help.
@allthings7734 жыл бұрын
Same, I'm also at 29:45. When I submit a new book it displays errorMessage, it doesn't matter if I submit valid data or not. Did you work out what was wrong?
@allthings7734 жыл бұрын
Mine is working now I had to replace the first part of the Create book route with the code from Github. No idea what was different, something must have been though! // Create Book Route router.post('/', upload.single('cover'), async (req, res) => { const fileName = req.file != null ? req.file.filename : null const book = new Book({ title: req.body.title, author: req.body.author, publishDate: new Date(req.body.publishDate), pageCount: req.body.pageCount, coverImageName: fileName, description: req.body.description })
@raipeter4 жыл бұрын
@@allthings773 it's working now, thanks. lol i don't think there's any change tho lol anyway, if it works it works haha
@shujjaahmed83604 жыл бұрын
@@allthings773 I used this code but still getting the error :(
@shai85592 жыл бұрын
i finished this video everything is working but i get application error on heroku.. its only working on my computer (in the video before it worked on heroku) any idea why?
@maniac14412 жыл бұрын
I got an error. Please help me Multer error :unexpeced fields.. at 29:00 .how to fix this
@jccorman58482 жыл бұрын
Some one found a correction, it's somewhere further down the comments here
@justinreidy87295 жыл бұрын
Running into a problem at 13 minutes, whenever I bring up the page(be it localhost or pushing it to heroku), I have an issue where whenever I go to change the author or put in a title, the page instantly reloads. EDIT: Figured it out thanks to Chrome's developer tools, forgot to close the anchor tag in my header partial so it was loading to the books/new page whenever I clicked inside the form... weird how it did that but im glad i got it fixed
@WebDevSimplified5 жыл бұрын
That had to be a frustrating bug to track down. I'm glad you figured it out.
@kirtisoni60764 жыл бұрын
getting an error during the file upload: CastError: Cast to ObjectId failed for value "5f3d49670bfd24277c033ab8 " at path "author". Error: Argument passed in must be a single String of 12 bytes or a string of 24 hex characters
@mavertan4 жыл бұрын
I doubt it's a useful advice by now, but your problem is almost certainly has something to do with value=" " Extra space at the end. Had the same exact error 😉
@immortal71674 жыл бұрын
did u solve it already? if yes plz tell the reason.
@kirtisoni60764 жыл бұрын
@@immortal7167 see the above reply and check if there is a space in between or not.
@gabrielnardes97413 жыл бұрын
@@mavertan Solved for me, thanks!
@javohiromonov41554 жыл бұрын
TypeError: Cannot read property 'filename' of undefined. How can I fix it? Pls help me.
@uchiha_sasuke_482 жыл бұрын
When i was trying to connect to Mongodb Atlas, there was an "MongoError: database name must be a string" in the terminal. Can someone solve this issue?
@AnkitSingh-eq4ge4 жыл бұрын
its been more then 11 hrs of debugging but stil getting error while unlinking the file . file is still uploading . Plzz help .... here is the error [Error: ENOENT: no such file or directory, unlink 'E: ode js first project\project\public\uploads\bookcovers\cover'] { errno: -4058, code: 'ENOENT', syscall: 'unlink', path: 'E:\ ode js first project\\project\\public\\uploads\\bookcovers\\cover'
@anuragparcha44834 жыл бұрын
At 9:00 , he gets the user.id as a field input. However, I have a system, where a User can log in and a session is created, can I somehow get the logged in user's id , or any information from the database for that matter directly, instead of asking author as an input field in the form? Like in a forum website liek reddit, when you are creating a new thread, the page doesn't ask you your username again as you are already logged in. Sorry, if its a dumb question, but im pretty now and this has me boggled. Thanks for any help in advance.
@hassanayasrah99082 жыл бұрын
what is the diffrent between pass 'new book()' and pass existing 'book' to the /new.ejs
@brunosoltoo2 жыл бұрын
My application is loading forever when I click in the Create button. Does anyone have any idea of what i'm possibly doing wrong? I've already tried to copy the code of Kyle for the books.js route, but the result is the same (and the informations aren't getting saved in the database).
@brknbeast38034 жыл бұрын
Hello. Don't know if you still respond to these videos, but I ran into an error. I am guessing it is because of outdated code, but cannot figure out the fix. Npm errors on the ".load()" call from "require('dotenv').load() I am guessing. Is there an updated way to require "dotenv"? Thank you.
@mahmoudsamy51304 жыл бұрын
use "config" instead of "load" because it's deprecated.
@universalworthy21692 жыл бұрын
Heroku is going to end their free tier, what is your suggestion for alternative? Please do the full stack series with the new choice. Thank you very much.
@teddyomondi3 жыл бұрын
make sure to change imageMimeTypes from 'images/jpeg' to 'image/png' and so on
@tangoalpha60133 жыл бұрын
Hello! I have an error while creating the new book. I checked everything also the other comments and tried to copy the text from github. My route for a new book generate the message: "'Error Creating Book'". How to troubleshoot this?
@teddydevil32 жыл бұрын
problem for me was under "create book route", when creating a new Book I wrote "pagecount: req.body.pageCount" with lowercase c instead of "pageCount" which is how I defined it in the schema. It wouldn't save because pageCount was a required attribute for Book and no value was assigned to it due to the typo.
@indigosay4 жыл бұрын
Who has problem on 39:55 with reading images. I solved this problem. Just use my variant github.com/xreider/mybrary/tree/seventhVideoSolved . Download it, open by Visual Studio Code, open terminal by clicking 'ctrl' + '~', and type in terminal: npm i That will install all packets Make file .env , .gitignore, fill it up, and here you go Then type 'npm run dev'. Not npm run devStart But I use 'pug' instead of 'ejs'
@3RM4L4 жыл бұрын
i am having a problem by creating a new book.I fill all the fields and again it says error,i console loged it and everything seems fine nothing is null or undefined,it shows the path name of the coverImage,id etc,its so fustrating :(.
@indigosay4 жыл бұрын
@@3RM4L just download my own file and use it. Make file .env with your secret data such like mongoodbconnection
@hyildiz6851 Жыл бұрын
I had the same Problem: My issue was in server.js where I had define the static folder public. in the line app.use(express.static('public')); I had an error. I wrote 'pulic' instead of public.
@stepanfau64803 жыл бұрын
I'm not able to create a book in the DB. It simply redirects me to /books, but strangely enough still shows the form with some items pre-filled. The covers are successfully getting saved to the public/uploads/bookCovers folder. Any ideas what could be causing this?
@stepanfau64803 жыл бұрын
EDIT: I had a typo in pageCount: req.body.pagecount, was supposed to be pageCount: req.body.pageCount,
@MichaelImo3 жыл бұрын
what is the point of setting book.coverImageName != null ? would it be easier to just say if(book.CoverImageName){foo} ? @31:28
@satyaviswapavanranga59153 жыл бұрын
at13:00, when I hit on localhost:3000/books/new it sends me to localhost:3000/books/
@carlonnrivers5 жыл бұрын
Ack!! It's getting complicated! But I'm not giving up! One question though, how do you also do a search query for the books made by similar authors? I tried copy pasting for the name but it crashed. Maybe it's a number? I don't know how to workaround. Edit: Thank you for the tutorial!
@WebDevSimplified5 жыл бұрын
It is a bit more complicated since if you want to search for books by author name you actually need to populate the author model in the query. With mongoose you can use .populate to populate the author model on the books so you can use that author model with your queries. I would do some reading on Mongoose and how to properly handle filtered joins.
@carlonnrivers5 жыл бұрын
@@WebDevSimplified I'll definitely look into .populate, because I don't know anything about it., so thanks. :) One more thing. I came here after watching your authentication tutorial where you referred to this series to learn how to make the authentication user based and on a server. So by the end of this series, joined with the knowledge from the authentication tutorial, would I be able to implement my own website/login system for multiple people to create accounts etc? I know it's not as simple as altering your book code into some user page, hat's why I'm asking. And if so, any other things you'd suggest reading up or learning in an attempt to create that? Tips and advice?
@WebDevSimplified5 жыл бұрын
@@carlonnrivers This series combined with the authentication video will be enough for you to create your own multi-user web application. It will not be easy, especially if it is your first time tackling such a project, but you will have all the knowledge you need to accomplish it. My biggest advice I can give is to start small with a simple application and login and only increase the scope of the project after you have accomplished the smaller scope first.
@carlonnrivers5 жыл бұрын
@@WebDevSimplified That's smart! Thank you very much, and I look forward to tackling the rest of the tutorials tomorrow onward! :D
@lookwhoneedsahobbie2 жыл бұрын
FYI, at 27:27 make sure you delete `const book = new Book()` from renderNewPage because I just experienced the weirdest bug where clicking the Add Book link would send me to the page for Books because books/new was failing to render.
@daro.a2 жыл бұрын
capo total!! muchas gracias
@lookwhoneedsahobbie2 жыл бұрын
@@daro.a de nada!
@mikhailmaharaj8945 ай бұрын
Thanks , exact issue here I think it had something to do with the open end if statement , you literally saved five hours of back tracking to fond my mistake , thanks G
@sdc024085 жыл бұрын
hi im always thank for you. my problem is book cover image is not come out. i changed "images/png" ->"image/png". i read all this reply but i cant solve my problem. when i create new book. in public/uploads/bookCovers/4efddd7ce633e7623f8df9620765998b. i think create book. but localhost:3000/books .i cant see image. i am not using heroku. i just use local. is this problem? or my webstrorm is problem? i check spelling several times! so please teach me @Web Dev Simplified i want to master this course!! thank you
@sdc024085 жыл бұрын
@Web Dev Simplified
@persidachita692 жыл бұрын
hey I'm getting the same problem. Did you manage to solve it?
@hyildiz6851 Жыл бұрын
@@sdc02408 I had the same Problem: My issue was in server.js where I had define the static folder public. In: app.use(express.static('public')); I had an error. I wrote 'pulic' instead of public.
@ChristopherRuthenbeck5 жыл бұрын
A lot of times you use the “if something != null” if block. Could you shorten it to just “if(something)”? For example, at ~36m37s you have “if (this.coverImageName != null)”. Won’t “if (this.coverImageName)” do the same thing since null is falsely?
@WebDevSimplified5 жыл бұрын
In this case you are correct. I like to be explicit though since it makes it easier for beginners to follow along and it also catches potential bugs. If (0) returns false while if (0 != null) is true. This can cause potential bugs.
@MnMEminem3 жыл бұрын
You must be fun at parties
@shai85592 жыл бұрын
when i try to add a new book without a title (to see if the image doesnt get saved), my site crash because "path title is required". any idea how i fix it to just have a new line of 'error creating a book' like you?
@nikolarahovic97813 ай бұрын
I'm sorry for the late response but i'm building this project right now and have found myself in your situation. I have been looking for a fix and debugging for a few hours, however my problem was that i was not using "await" when trying to save the book in the post route: try { const newBook = await book.save() // res.redirect(`books/${newBook.id}`) res.redirect(`books`) } catch { renderNewPage(res, book, true) } as you can see when i'm creating the "newBook" variable i am awaiting the saving process since it is asynchronous, this fixed it for me, hope it helps!
@boka042 жыл бұрын
Drinking game - Drink a shot every time we need to install a new library :D
@omnikharge52403 жыл бұрын
I didn't understand the logic of fetching different values from database and putting them into value attribute in "html forms"
@kanyin2 жыл бұрын
Can I do all this with MySQL?
@pakiman6984 жыл бұрын
So I keep getting an error when creating book and I am not sure how to track down this error. I copied all your code on Github as well but it still keeps happening
@narenkulkarni114 жыл бұрын
Same, that error even I haven't been able to solve yet. Anyone has got a solution to that problem please help.
@@sachinbhutani8177 check the mime type array .In that u may have written images/png but the correct type is image/png. This solved the problem for me.
@sachinbhutani81774 жыл бұрын
@@rishhh3217 yup that was the problem , thanks bro
@hassanayasrah99082 жыл бұрын
if not include required feild , it show error, then when i include it and set all the feild right , it won't successfully create book untel i refresh the page, how to fix this
@shai85592 жыл бұрын
any fix bro?
@Shoutiez4 жыл бұрын
Hi Kyle, Could you make a video about query string with React Router such as filtering data in an eCommerce app? When user checked on check box and the query string will be somthing like '?category=xxx&brand=yyy' I can not find the tutorial on this topic because most of them only used state to store the filter but in the real world scenario I see all the eCommerce app using query string.
@MrBestGamer4 жыл бұрын
10:00 Can someone pls explain me why we are comparing these two IDs.
@programmerslife014 жыл бұрын
@@reds1122 When you see _id think of it just like syntax, and author_id gives an error syntax in JS, because in MongoDB data is stored as documents. These documents are stored in MongoDB in JSON (JavaScript Object Notation) format. So _id it's a JSON syntax. Hope this can help.
@anuragparcha44834 жыл бұрын
@@programmerslife01 How do I handle the author id, if I don't want to put an author field input, rather, If a user is logged in and is creating a post, I want to automatically get the user.id from the session, is that possible? Sorry if this is a dumb question, I am very new.
@casey53903 жыл бұрын
so in "Model-View-Controller" style, server.js is the controller right?
@DarkCloud73 жыл бұрын
The files in the "routes"-folder are the controllers. But server.js instructs the app to use the controllers. (P.S.: As I understand it server.js is kinda like Startup.cs in .net core, if you are familiar with that)
@umaedu3097 Жыл бұрын
could someone help me understand how to make a three different page website according top this model? thank you :)
@michaelthomas42923 жыл бұрын
I keep getting an error : Cannot read property 'toISOString' of undefined, for the auto-populating code for date. How can I get around this. I create the book object and pass it into the render call, and the other fields work fine, it's jsut the date field that throws this error. How anyone else had this problem?
@WydeZ Жыл бұрын
have you found a solution
@goodwish15433 жыл бұрын
Thanks for the great teaching. If I want to migrate to PostgreSQL from MongoDB, what database library will you recommend to replace the mongoose? Is Sequelize or pg a good one?
@snc0lt4 жыл бұрын
for some reason when i make the relation between books and authors(by using moongose.Schema.Types.ObjectId) it doesn't let me create a new book...! any suggestions..? the error: { ValidationError: Book validation failed: author: Cast to ObjectID failed for value "5eb1af4f5a9d6d2b6ba57843 " at path "author" at ValidationError.inspect (/home/snc0lt/awesomeness/books/node_modules/mongoose/lib/error/validation.js:59:24) at formatValue (internal/util/inspect.js:491:31) at inspect (internal/util/inspect.js:189:10) at Object.formatWithOptions (util.js:84:12) at Console.(anonymous function) (console.js:196:15) at Console.warn (console.js:213:31) at router.post (/home/snc0lt/awesomeness/books/routes/books.js:69:13) at process._tickCallback (internal/process/next_tick.js:68:7) errors: { author: { CastError: Cast to ObjectID failed for value "5eb1af4f5a9d6d2b6ba57843 " at path "author" at new CastError (/home/snc0lt/awesomeness/books/node_modules/mongoose/lib/error/cast.js:29:11) at model.$set (/home/snc0lt/awesomeness/books/node_modules/mongoose/lib/document.js:1030:7) at model._handleIndex (/home/snc0lt/awesomeness/books/node_modules/mongoose/lib/document.js:806:14) at model.$set (/home/snc0lt/awesomeness/books/node_modules/mongoose/lib/document.js:756:22) at model.Document (/home/snc0lt/awesomeness/books/node_modules/mongoose/lib/document.js:119:12) at model.Model (/home/snc0lt/awesomeness/books/node_modules/mongoose/lib/model.js:95:12) at new model (/home/snc0lt/awesomeness/books/node_modules/mongoose/lib/model.js:4553:13) at router.post (/home/snc0lt/awesomeness/books/routes/books.js:57:16) at Layer.handle [as handle_request] (/home/snc0lt/awesomeness/books/node_modules/express/lib/router/layer.js:95:5) at next (/home/snc0lt/awesomeness/books/node_modules/express/lib/router/route.js:137:13) at Immediate. (/home/snc0lt/awesomeness/books/node_modules/multer/lib/make-middleware.js:53:37) at runCallback (timers.js:706:11) at tryOnImmediate (timers.js:676:5) at processImmediate (timers.js:658:5) message: 'Cast to ObjectID failed for value "5eb1af4f5a9d6d2b6ba57843 " at path "author"', name: 'CastError', stringValue: '"5eb1af4f5a9d6d2b6ba57843 "', kind: 'ObjectID', value: '5eb1af4f5a9d6d2b6ba57843 ', path: 'author', reason: [MongooseError] } }, _message: 'Book validation failed', name: 'ValidationError' }
@sebastiencounen68184 жыл бұрын
Exactly the same. If anyone has any idea, it'd be great !
@sebastiencounen68184 жыл бұрын
Look at your ejs file which contains the select and look if there is no space between the and the " in the value.
@abdessalemaghrib4 жыл бұрын
@@sebastiencounen6818 Thank you bro
@noumanahmad23133 жыл бұрын
Polanco if you have found the solution please post it as I have the same issue
@rp-wd1nq4 жыл бұрын
Has any1 used this method for multiple images? Trying to get "router.post("/", upload.array('cover', 2,),..." to work but having trouble creating the string of multiple path names in mongodb. I know it's off topic, but if any1 has a solution I'd appreciate it!
@gscc27704 жыл бұрын
Why must we define instead of ?
@rubenverster2503 жыл бұрын
books variable has already been declared, we're just overwriting the current value :P
@karthikadyar9725 жыл бұрын
I get error while adding new books can someone help??
@tictactoc93114 жыл бұрын
Me too, I trying to debugging, and I got an error while doing book.save() , but I don't know how to solved it
@agnieszkalewandowska98964 жыл бұрын
@@tictactoc9311 There is mistake in code. Change "images/png" ->"image/png", the same for jpeg and gif
@nikhilkatiyar24624 жыл бұрын
@@agnieszkalewandowska9896 I am facing the same problem but did not get the solution yet. I have also changed images -> image. But no luck
@elbezz3 жыл бұрын
@@nikhilkatiyar2462
@shai85592 жыл бұрын
@@agnieszkalewandowska9896 i love you brooooooooooooooo
@ih47225 жыл бұрын
I am at minute 30, and when i press the create button in the new Book form to create a book the URL changes to \books but it does not redirect the page, am still at the new book page. Also there is no file created under the upload/bookCover folder!.
@ih47225 жыл бұрын
UNBELIEVABLE! after an hour i just notice that i have written req.file.fileName instead of req.file.filename :(
@WebDevSimplified5 жыл бұрын
That is frustrating. I'm glad you were able to figure it out. Typos are the most annoying bugs to fix.
@AnnieTaylorChen5 жыл бұрын
@@WebDevSimplified I definitely felt the pain. When this happens I start to think of everything else, will test this and that, compare with the teacher's code line by line, but sometimes since in my head I don't realize I wrote it wrong I would even miss that. In the end you finally found out you are just like, WTF a few hours of my life are wasted on misspelling something!
@esbrasill5 жыл бұрын
@@WebDevSimplified It seems the "catch" also hides the actual error, thus making it harder to debug
@WebDevSimplified5 жыл бұрын
Catch does consume the error but you can always write this to print the error since catch gives us the error it catches. catch (e) { console.error(e) }