I want to get just one document from Mongodb collection, I am using Angular 8 on the front-end and Node js for the server, so when I request the specific url to get the data, Angular seems to do the request but the server does not respond. I tried to do a console log on the server side to verify if the request is reached but the console log is never printed.
This is the code for the function on the Angular typescript file:
searchUser(value) {
if (this.query !== '' && this.query.length > 0) {
this.ps.search(value); //ps is the service
} else {
console.log('Incorrect');
}
}
This is the code in the Service file:
search(value) {
return this
.http
.get(`${this.uri}/searchUser/${value}`);
}
This is the Node get request function:
app.get('/searchUser/:value', function (req, res) {
let value = req.params.value;
console.log(value + ' <<< value in the server');
user.find({ user: value}, function(err, doc) {
if(err) {
console.log(err);
}else {
// res.json(res);
console.log(doc);
}
});
})