Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- async function getRecipe() {
- try{
- console.log('before attributes')
- const attributes = handlerInput.attributesManager.getSessionAttributes();
- console.log('before url')
- const url = `https://api.edamam.com/search?q=${attributes.currentSuggestedFood}&app_id=${FOOD_APP_ID}&app_key=${FOOD_APP_KEY}`; //&from=0&to=3&calories=591-722&health=alcohol-free this was on the end of the uri
- console.log('after url')
- request.get(url, async (error, response, body) => {
- // let json = JSON.parse(body);
- console.log('error:', error); // Print the error if one occurred
- console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
- console.log('body:', body); // Print the body
- //const theRecipe = await body;
- const payload = await JSON.parse(body)
- console.log("The ingredients for "+ payload.q + " is: ")
- console.log(payload.hits[0].recipe.ingredientLines)
- return await (payload.hits[0].recipe.ingredientLines);
- });
- }
- catch(err){
- console.log('before error statement in catch')
- console.error('There was an error: ', + err)
- }
- };
Add Comment
Please, Sign In to add comment