My Angular application has a TypeScript page that makes calls to Google Maps Timezone API. However, I am currently storing both the url and key as hardcoded strings in my code.
I'm questioning whether this is a good practice and wondering what would be the best way to store these values (url, key)?
Should I store them in the environment file?
Or should I fetch them from the server every time they are needed?
Maybe there's another file within the Angular project where they could be stored?
Currently, I construct the URL by hardcoding it in the .ts file like this:
const url = 'https://maps.googleapis.com/maps/api/timezone/json?location=' + this.latitude.value + ',' + this.longitude.value + '×tamp=' + Math.floor(Date.now() / 1000).toString() + '&key=' + 'my-google-key';
const timeZoneResult = await fetch(url, {
method: 'GET'
});
const timeZone = await timeZoneResult.json();