Skip to content

Instantly share code, notes, and snippets.

@tanvirstreame
Last active May 25, 2020 21:40
Show Gist options
  • Select an option

  • Save tanvirstreame/8db36b580aced32c004b7a07bc9c7850 to your computer and use it in GitHub Desktop.

Select an option

Save tanvirstreame/8db36b580aced32c004b7a07bc9c7850 to your computer and use it in GitHub Desktop.
programming hero Tareq Rahman task solved
app.get('/product/:key', (req, res) => {
const key = req.params.key;
client = new MongoClient(uri, { useNewUrlParser: true },{useUnifiedTopology: true});
client.connect(err => {
const collection = client.db("onlineStore").collection("products");
collection.findOne({key},(err, documents)=>{
if(err){
console.log(err)
res.status(500).send({message:err});
}
else{
res.send(documents);
}
});
client.close();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment