Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

111
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda