Guest User

Untitled

a guest
Dec 18th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. var search_keyword = "cafe+seoul";
  2. const api_key = "";
  3. var url = "https://maps.googleapis.com/maps/api/place/textsearch/json?query=" + search_keyword + "&key=" + api_key;
  4.  
  5. https.get(url, function (res) {
  6. var body = '';
  7.  
  8. res.on('data', function (chunk) {
  9. body += chunk;
  10. });
  11.  
  12. res.on('end', function () {
  13.  
  14. var response = JSON.parse(body);
  15.  
  16. pool.getConnection(function (err, conn) {
  17.  
  18. if (err) {
  19. if (conn) {
  20. conn.release;
  21. }
  22. }
  23. //INSIDE DB
  24. // for (var i = 0; i < 20; i++) {
  25. // var place_id = response.results[i].id;
  26. // var data = {
  27. // place_id: place_id
  28. // };
  29. // conn.query('INSERT INTO place_id SET ?', data);
  30. // }
  31.  
  32.  
  33. var next_page_token = response.next_page_token;
  34. console.log(next_page_token);
  35. var next_page_url = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?pagetoken=" + next_page_token + "&key=" + api_key;
  36. console.log(next_page_url);
  37. // if (response.next_page_token == null) {
  38. // break;
  39. // }
  40.  
  41. })
  42. });
  43. });
  44.  
  45. {
  46. "html_attributions" : [],
  47. "results" : [],
  48. "status" : "INVALID_REQUEST"
  49. }
Add Comment
Please, Sign In to add comment