Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

110
Views
Fetch Location using google Api

I am trying to get the latitude and longitude of user location using google api

I have tried doing this using the fetch method in javascript but I do not get any response. There's no error or anything. The documentation says to fetch it this way: https://www.googleapis.com/geolocation/v1/geolocate?key=MY_API_KEY

How I fetch it:

const res = await fetch(https://www.googleapis.com/geolocation/v1/geolocate?key=MY_API_KEY) const response = await res.json()

When I first did it like above I got an error because it returned nothing which I found out after console.logging res.text() I do not know what I'm doing wrong In the documentation they equally said something about including Request body but it's optional, So I have no need to include it. Please do you have any ideas on what I'm doing wrong?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I believe you need to send this as a POST request according to the documentation you linked. By default fetch sends a GET request.

To do that you just need to pass in the request type to the fetch function

const response = await fetch(<URI>,{method:'POST'});
const res =  await response.json()
console.log(res)
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!