Guest User

Untitled

a guest
Dec 13th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. async function getRecipe() {
  2.  
  3. try{
  4. console.log('before attributes')
  5. const attributes = handlerInput.attributesManager.getSessionAttributes();
  6. console.log('before url')
  7. 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
  8. console.log('after url')
  9. request.get(url, async (error, response, body) => {
  10. // let json = JSON.parse(body);
  11. console.log('error:', error); // Print the error if one occurred
  12. console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
  13. console.log('body:', body); // Print the body
  14.  
  15. //const theRecipe = await body;
  16. const payload = await JSON.parse(body)
  17. console.log("The ingredients for "+ payload.q + " is: ")
  18. console.log(payload.hits[0].recipe.ingredientLines)
  19.  
  20. return await (payload.hits[0].recipe.ingredientLines);
  21.  
  22. });
  23. }
  24. catch(err){
  25. console.log('before error statement in catch')
  26. console.error('There was an error: ', + err)
  27. }
  28. };
Add Comment
Please, Sign In to add comment