Conversation
…essed through an API
ddbruce
left a comment
There was a problem hiding this comment.
As I wrote in one location, I think changing the JS variables (server + client sides) to lat and long would be good.
| const response = fetch('/locale') | ||
| .then((response) => response.json()) | ||
| .then((data) => { | ||
| locale = data; | ||
| updateDate(); | ||
| setInterval(() => updateDate(), 2000); | ||
| }); No newline at end of file |
There was a problem hiding this comment.
This can be handled without the let locale; up above, particularly because locale should be immutable. Maybe something like:
const locale = await fetch("/locale");
const [{lat}, {long}] = locale.json();
setInterval(() => updateDate(lat, long), 2000);
This may not be entirely correct syntax-wise, but I think it's a sleeker way to handle it than using .then(). I realize it involves slight restructuring of updateDate(), but it could be handled in other ways, too. You may be able to leave lat and long as globals consts and be done. Let me know your thoughts.
| const PORT = process.env.PORT || 8080; | ||
| const WEBSITE_ACCESS_TOKEN = process.env.WEBSITE_ACCESS_TOKEN; | ||
| const HERALD_TOKEN = process.env.HERALD_TOKEN; | ||
| const LOCALE = {longitude: process.env.LONGITUDE, latitude: process.env.LATITUDE}; |
There was a problem hiding this comment.
Please abbreviate the JS variables to lat and long, respectively, just for brevity's sake. No problem keeping the env vars as the full word—that's your choice.
Add an endpoint for geographic info and move it from
whiteboard.jsto the enviornment file