Errors when we have a user that was not signed in. Fixed to unpack the username value first, then pass it to the function.
This commit is contained in:
		| @@ -10,15 +10,16 @@ const searchHistory = new SearchHistory(); | ||||
| function searchRequestController(req, res) { | ||||
|    const user = req.loggedInUser; | ||||
|    const { query, page, type } = req.query; | ||||
|    const username = user == undefined ? undefined : user.username; | ||||
|  | ||||
|    Promise.resolve() | ||||
|       .then(() => searchHistory.create(user, query)) | ||||
|       .then(() => searchHistory.create(username, query)) | ||||
|       .then(() => requestRepository.search(query, page, type)) | ||||
|       .then((searchResult) => { | ||||
|          res.send(searchResult); | ||||
|       }) | ||||
|       .catch((error) => { | ||||
|          res.status(500).send({ success: false, error: error.message }); | ||||
|          res.status(500).send({ success: false, error: error }); | ||||
|       }); | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user