Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

112
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda