Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1.  
  2. module.exports.getMoviesByGenre = async (event) => {
  3.  
  4. const keyword= event.currentIntent.slots["genre"];
  5. //const keyword= "action";
  6. const baseURL="https://api.themoviedb.org/3/";
  7. const url = baseURL+"search/movie?api_key=066b155baf4b9fc58ac620023fb8b5e5" +"&query="+ keyword;
  8. var movieName="";
  9. try {
  10. const response = await axios.get(url);
  11. const data=response.data;
  12. for (var i=0;i<5;i++){
  13. var movieName= movieName + "Name :"+ data.results[i].title+"; ";
  14. }
  15.  
  16. return {
  17. "sessionAttributes": {},
  18. "dialogAction": {
  19. "type": "Close",//close means LeEX doesn't expect anyresponse back from user
  20. "fulfillmentState": "Fulfilled",
  21. "message": {
  22. "contentType": "PlainText",
  23. "content": movieName
  24. }
  25. }
  26. }
  27. } catch (error) {
  28. console.log(error);
  29. }
  30. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement