Advertisement
Guest User

get my ip + get my location

a guest
Mar 19th, 2018
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $.get("https://jsonip.com/", function (data) {
  2.   console.log(data);
  3.   var query = `{
  4.     getLocation(ip: "${data.ip}") {
  5.       country {
  6.         names {
  7.           en
  8.         }
  9.       }
  10.     }
  11.   }`;
  12.  
  13.   $.post('https://api.graphloc.com/graphql', {query: query}).done(res => {
  14.     console.log(res.data.getLocation.country.names.en);
  15.   });
  16. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement