Invalid Fetch

I got the following error when trying to Fetch a 3rd party. I need a help ASAP.


Unhandled rejection FetchError: invalid json response body at Driving Directions, Traffic Reports &amp; Carpool Rideshares by Waze reason: Unexpected token < in JSON at position 0


My backend code is:

const url= “Driving Directions, Traffic Reports &amp; Carpool Rideshares by Waze
return fetch(url, {
method: ‘get’,
// headers: {
//‘Content-Type’: ‘application/json’
// },
// body: JSON.s({
someVariable: (latitude, longitude)
// })
}).then( (httpResponse) => {
console.log(httpResponse.json())
if (httpResponse.ok) {
return httpResponse.json();
} else {
return Promise.reject(“Fetch did not succeed”);
}
} );

It sounds as if you are getting an invalid response from Waze and you will have to check with them regarding the proper way to send a fetch query.

To see fetch demonstrated with several different services:

Send Email with SendGrid REST Interface

Send an email using the SendGrid REST API.

Stripe Payment Processing

Integrate the Stripe Payment processing system into a site. Three levels of user access are demonstrated: visitor, freemium (registered), and premium (paid).

Using the Places API from Google Map Services

Demonstrates geolocation queries using the Google Maps Places API web services. The queries are performed in backend (server-side) web modules.

Have you tried Postman?

What do you mean by Postman ?

You can use Postman to test API calls; check out https://www.getpostman.com/.