Last active
May 25, 2020 21:40
-
-
Save tanvirstreame/8db36b580aced32c004b7a07bc9c7850 to your computer and use it in GitHub Desktop.
programming hero Tareq Rahman task solved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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