Community
how to connect a script to samsara api
i have copied your script code and put my samsara key api, but when it runs an error of authentication appeared
Access to fetch at 'https://api.samsara.com/fleet/vehicles' from origin 'http://localhost' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
how can i do for connect my php system?
script type="text/javascript">
const options = {
method: 'GET',
headers: {
Accept: 'application/json',
Authorization: 'Bearer MY_SAMSARA_KEY'
}
};
fetch('https://api.samsara.com/fleet/vehicles', options)
.then(response => console.log(response))
.catch(err => console.error(err));