I am using Node.js with mongoose for my backend. For a couple end points, I need to find items with matching item_categories and a matching item_name. However when item_name is \ the api is catches an error and returns an error message. Why is this throwing an error? I've searched online and there isn't much explaining why this happens. If item_name isn't \ then everything works correctly and the api returns a response. Also if item_name is \ ... then it works but if it is ...\ then it fails.
const items = await item.find({item_name: new RegExp(data.item_name, "i")});
const items = await item.find({item_category:{ $all:data.item_category}, item_name: new RegExp(data.item_name, "i")});