Skip to content

Instantly share code, notes, and snippets.

@lakshaygupta21
Created May 28, 2020 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lakshaygupta21/7acc9e009008829c29e189862d84fe9b to your computer and use it in GitHub Desktop.
Save lakshaygupta21/7acc9e009008829c29e189862d84fe9b to your computer and use it in GitHub Desktop.
/**
* @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