I'm trying to get the latitude and longitude from the geocoder API using fetch in js. When I check the response , the url is malformed, and it prepend it with localhost.
const getLatLong = async () => {
const response = await fetch(
{
url: 'https://geocoding.geo.census.gov/geocoder/locations/address?street=4600+Silver+Hill+Rd&city=Washington&state=DC&benchmark=2020&format=json;',
mode: 'no-cors',
method: "get",
headers: {
'Access-Control-Allow-Origin': '*',
"Content-Type": "application/json"
}
});
console.log(response);
const myJson = await response.json(); //extract JSON from the http response
console.log(myJson);
// do something with myJson
}