Newbie writers: how do authors deal with the disappointment of putting months of hard work into a book and then watching it fade into oblivion with very few or zero buyers?

As much effort as we put into writing a book, the real hard work comes after we publish. There are millions of other books out there, so if you aren’t spending time building your audience via social media, advertising (when it makes sense to), networking with other authors, and/or finding other marketing opportunities that will put your book in front of your preferred audience, it will quickly fade. So if you are disappointed by a lack of sales, put that energy towards engaging your audience and getting the word out.
Other things to look at as well. Make sure your cover and book description are the best they can be. Also, if you published independently - hopefully you had a good editor, if not (and even if you did, it still can’t hurt), go back over your book text (and e-book as well if you have both) and make sure everything is formatted correctly and there aren’t any glaring typos. Nothing will turn off potential readers quicker than bad formatting or other text errors.
The point is that writing the book is just the beginning. Too many people think that once you’ve published all you have to do is sit back and watch the $$$ roll in. Unfortunately, it doesn’t usually work that way. Especially when one is first starting out.