I've been playing with this API link that allows me to find the duration of a trip between addresses in the format of latitude and longitude. When I paste this link on my browser I get a json object and therefore "it is working" (no credentials, etc).
The challenge arises when I would like to fetch the data from the API:
fetch('http://router.project-osrm.org/trip/v1/driving/-43.20940000000002,-22.911;-48.84870000000001,-26.3045?overview=false')
.then(response => {
return response.json()
})
.then(data => {
// Work with JSON data here
console.log(data)
})
.catch(err => {
// Do something for an error here
})
And I get this error message in the firefox console:
Content Security Policy: The page’s settings blocked the loading of a resource at http://router.project-osrm.org/trip/v1/driving/-43.20940000000002,-22.911;-48.84870000000001,-26.3045?overview=false (“connect-src”).
After trying multiples different method I finally gave up and came here seeking for help. Therefore, could someone explain me what is wrong with the request? Also, why does it works when I paste on my browser but not when I do it by fetch? Just one more, I've realized that my posted code snipped in this question returns me the data I would like to receive. Why in this context it works?
Thank you in advance