Open Madhav-Somanath opened 4 years ago
I have the same issue. it keeps saying ShortUrl is undefined and I have not got a clue why, as I followed everything to a T.
Everything starts up and works fine but when I click the shortened link or open in new tab and it just throws that error.
In the pictures provided, If I remove the lines of code in the blue bracket I get the "Cannot Get" error page just fine. But as soon as I paste the lines of code back in. Instant error and nothing loads.
cant start server.
Faced same problem. Got solved after installing MongoDB.
app.get('/:shortUrl',async (req,res) =>{
shortUrl.findOne({ short:req.params.shortUrl } ,function(err,docs){
if (docs == null ) return res.sendStatus(404)
count = docs['click'] + 1
var myquery = { short:req.params.shortUrl };
var newvalues = { $set: {click: count } };
shortUrl.updateOne(myquery,newvalues,function(err,res){
})
res.redirect(docs['full'])
})
i guess it will help
Got the same error. Pretty sure something's wrong with the code as the forked copy of the GitHub code throws the same error.
cant start server.