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

223
Views
Error: Failed to execute 'fetch' on 'Window': Request with GET/HEAD method cannot have body

I'm using fetch to call Google TimeZone. But I'm getting an error when trying to pass the lat/lng and timestamp in as body paramters.

Error: Failed to execute 'fetch' on 'Window': Request with GET/HEAD method cannot have body

Here is my code. Does Google allow it to be called this way?

const data = new FormData();
data.append('location', this.latitude.value + ',' + this.longitude.value);
data.append('timestamp', Math.floor(Date.now() / 1000).toString());
data.append('key', 'my google API key')
const timeZoneResult = await fetch('https://maps.googleapis.com/maps/api/timezone/json', {
  method: 'GET',
  headers: {},
  body: data,
});
const timeZone = await timeZoneResult.json();

This way, all in the url string, works fine!

https://maps.googleapis.com/maps/api/timezone/json?location=39.6034810%2C-119.6822510&timestamp=1331161200&key=myKeyHere

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

0

The error says where the problem is. Method GET cannot have a body. Place the data as a query string.

https://maps.googleapis.com/maps/api/timezone/json?location=...&timestamp=...
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!