Skip to content

Commit

Permalink
Merge pull request #6 from raphaellaude/dev-prod-endpoints
Browse files Browse the repository at this point in the history
set up different endpoints and env vars
  • Loading branch information
raphaellaude authored Feb 25, 2024
2 parents f24e8d3 + 6e8c8e1 commit cd588eb
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion pluto-hist/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function setYear(year) {

async function queryFeatures(year, lat, lng) {
const response = await fetch(
`https://pluto-hist-backend-v2.fly.dev/single_year_point_lookup/${year}/${lat}/${lng}`,
`${import.meta.env.VITE_API_URL}/single_year_point_lookup/${year}/${lat}/${lng}`,
);
if (response.ok) {
if (response.status === 204) {
Expand All @@ -53,7 +53,21 @@ async function queryFeatures(year, lat, lng) {
}
}

async function wakeServer() {
console.log(import.meta.env.VITE_API_URL);
const response = await fetch(`${import.meta.env.VITE_API_URL}/healthcheck`);
if (response.ok) {
const data = await response.text();
console.log(data);
} else {
const data = await response.text();
console.log("Uh oh!" + " " + data);
}
}

map.on("load", function () {
wakeServer();

years.forEach((y, index) => {
let isVisible = index === currentYearIndex ? "visible" : "none";
let layerData = data[y];
Expand Down

0 comments on commit cd588eb

Please sign in to comment.