codeforboston / home-energy-analysis-tool

https://www.codeforboston.org/projects/
MIT License
12 stars 31 forks source link

Investigate method for looking up weather station data #20

Closed jkwan2011 closed 1 year ago

jkwan2011 commented 1 year ago

We need to look up weather station data for the calculation of heat degree days. There are APIs online (e.g. https://www.degreedays.net) that might be able to help.

spghtti commented 1 year ago

Starting a google sheet to compare API options https://docs.google.com/spreadsheets/d/1U8RnKo2cHlmG7Q6yCjSw3Qgd1t-uNCvvIvvm74XLk7s/edit?usp=sharing

thadk commented 1 year ago

Use Archive to retrieve archival weather (do not use for last 6-7 days of weather)

plocket commented 1 year ago

I know we rejected useFetcher, but it might be a better solution than useLoader (because of the complications in getting useLoader to have multiple loaders) if we can use it right. GPT 3.5 has this to say about using useFetcher that may be worth trying (though it says this isn't directly from Remix, so ~Y~OMMV):

To use useFetcher to fetch data from an API without using it for a form, you can define a custom fetcher function and pass it to useFetcher. Here's an example:

import { useFetcher } from "@remix-run/react";

const fetchData = async () => {
  const response = await fetch("https://api.example.com/data");
  const data = await response.json();
  return data;
};

export function MyComponent() {
  const fetcher = useFetcher(fetchData);
  const { isLoading, error, data } = fetcher;

  if (isLoading) {
    return <p>Loading...</p>;
  }

  if (error) {
    return <p>Error: {error.message}</p>;
  }

  return (
    <div>
      {/* Render the fetched data */}
      <pre>{JSON.stringify(data, null, 2)}</pre>
    </div>
  );
}

Please note that the sources provided are not directly related to Remix, but they offer insights on using similar hooks and concepts in React applications.

plocket commented 1 year ago

We're using useLoader for now.