MERN Stack - Search box returning empty array

Hi. I'm developing a MERN stack web app, and am encountering a problem with my search box where if keywords provided in the search box do not match any product in the database, array returns [], whereas it is supposed to throw an error and therefore trigger react toastify for a 'product not found' notification. I'm unsure whether the problem is in the front or backend part of the project, but I provided all of the files I thought were of use. If anyone could help, I'd be very grateful. Let me know if you would like to see another file that is not included here: https://gist.github.com/deahlt/dbb9f613271f74f59be69b9f5172e847
Gist
When keywords provided in the search box do not match any product in the database, array returns [], whereas it is supposed to throw an error and therefore trigger react toastify for a 'pro...
Was this page helpful?