Created
March 15, 2020 22:16
-
-
Save iMichaelOwolabi/4fee32d213bfdcdc75e498fd9a59175f to your computer and use it in GitHub Desktop.
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
const express = require('express'); | |
const app = express(); | |
const port = 3000; | |
const axios = require('axios'); | |
app.get('/recipe/:fooditem', async (req, res) => { | |
try { | |
const fooditem = req.params.fooditem; | |
const recipe = await axios.get(`http://www.recipepuppy.com/api/?q=${fooditem}`); | |
return res.status(200).send({ | |
error: false, | |
data: recipe.data.results | |
}); | |
} catch (error) { | |
console.log(error) | |
} | |
}); | |
app.listen(port, () => { | |
console.log(`Server running on port ${port}`); | |
}); | |
module.exports = app; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment