I am trying to fetch data from an API using fetch() on javascript. This is my code
async function getCS() {
try {
const response = fetch('http://chargepoints.dft.gov.uk/api/retrieve/registry/lat/51.545581/long/-0.077301/dist/0.2/format/json',
{
method: 'GET',
mode: 'no-cors',
headers: {
'Access-Control-Allow-Origin': '*',
'content-type': 'application/json'
}
})
return response;
} catch (error) {
throw error.message;
}
}
console.log(getCS());
The request returns Status 0 and I dont get any data. can i get help please