Skip to content

Instantly share code, notes, and snippets.

@iMichaelOwolabi
Created March 15, 2020 22:16
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 iMichaelOwolabi/4fee32d213bfdcdc75e498fd9a59175f to your computer and use it in GitHub Desktop.
Save iMichaelOwolabi/4fee32d213bfdcdc75e498fd9a59175f to your computer and use it in GitHub Desktop.
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