Created
May 28, 2020 18:38
-
-
Save lakshaygupta21/7acc9e009008829c29e189862d84fe9b to your computer and use it in GitHub Desktop.
This file contains 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
/** | |
* @swagger | |
* /api/fruits: | |
* get: | |
* tags: | |
* - Fruits | |
* description: Returns all fruits | |
* produces: | |
* - application/json | |
* responses: | |
* 200: | |
* description: An array of fruits | |
* schema: | |
* $ref: '#/components/schemas/fruits' | |
* 500: | |
* description: SERVER ERROR | |
*/ | |
router.get('/fruits', async(req, res) => { | |
try { | |
var fruits = await Fruits.find(); | |
//console.log(fruits) | |
return res.json({ | |
fruits | |
}) | |
} catch (err) { | |
res.status(500).send('Server error') | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment