I Connected my mongoose to MongoDb database and this database hosted by mLab.
try {
mongoose.connect('mLab Hosting Url', { useNewUrlParser: true })
} catch (e) {
console.error('An Error Occurred When Trying Connect To MongoDb.', e);
}
And hosted my Express api which is require connecting to this db by firebase hosting.
router.get('/hello', (request, response) => {
try {
User.findOne({ email: 'm.yaman.katby@gmail.com' }).then((result) => {
return response.status(200).json(result);
}).catch((e) => {
return response.status(700).json(e);
});
} catch (e) {
return response.status(700).json(e);
}
});
Now when I call the api locally it is work, When i deploy the api to firebase and call it not work and return this error "Error: could not handle the request"