-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: plocket <plocket@users.noreply.github.com> Co-authored-by: Thad Kerosky <thadk@users.noreply.github.com> Co-authored-by: Leopardfoot <Leopardfoot@users.noreply.github.com>
- Loading branch information
1 parent
76c5687
commit ec06767
Showing
3 changed files
with
43 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export type DailyWeather = { | ||
time: string[], | ||
temperature_2m_max: number[] | ||
} | ||
|
||
export type Weather = { | ||
daily: DailyWeather | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,22 @@ | ||
import { loader } from "#app/root.tsx"; | ||
import test from "@playwright/test"; | ||
import { json } from "@remix-run/node"; // or cloudflare/deno | ||
import { useLoaderData } from "@remix-run/react"; | ||
|
||
export async function loader() { | ||
const href = 'https://archive-api.open-meteo.com/v1/archive?latitude=52.52&longitude=13.41&daily=temperature_2m_max&timezone=America%2FNew_York&start_date=2022-01-01&end_date=2023-08-30&temperature_unit=fahrenheit'; | ||
const res = await fetch(href); | ||
return json(await res.json()); | ||
} | ||
// weather `loader` is in root.tsx | ||
|
||
export function WeatherExample() { | ||
|
||
const gists = useLoaderData<typeof loader>(); | ||
const one_loader = useLoaderData<typeof loader>(); | ||
if (!one_loader.weather) { | ||
return <div>Loading weather...</div>; | ||
} | ||
const time: string = one_loader.weather.daily?.time[0] | ||
const temp: number = one_loader.weather.daily?.temperature_2m_max[0] | ||
|
||
return ( | ||
<ul> | ||
{'5'} | ||
</ul> | ||
<div> | ||
<span>time/temp first item: {time}/{temp}</span> | ||
</div> | ||
); | ||
} | ||
|
||
// import { useFetcher } from "@remix-run/react"; | ||
// import { useEffect } from "react"; | ||
|
||
// export function WeatherExample() { | ||
|
||
// // 2 separate routes - including one that doesn't load | ||
// // the python to avoid the long restart times. | ||
|
||
// /* | ||
// Historical archival records API: https://archive-api.open-meteo.com/v1/archive?latitude=52.52&longitude=13.41&daily=temperature_2m_max&timezone=America%2FNew_York&start_date=2022-01-01&end_date=2023-08-30&temperature_unit=fahrenheit | ||
// Current week forecast API: https://api.open-meteo.com/v1/forecast?latitude=52.52&longitude=13.41&daily=temperature_2m_max&timezone=America%2FNew_York&past_days=5&forecast_days=1&temperature_unit=fahrenheit | ||
// */ | ||
// const fetcher = useFetcher(); | ||
// const href = 'https://archive-api.open-meteo.com/v1/archive?latitude=52.52&longitude=13.41&daily=temperature_2m_max&timezone=America%2FNew_York&start_date=2022-01-01&end_date=2023-08-30&temperature_unit=fahrenheit'; | ||
|
||
// // trigger the fetch with these | ||
// // <fetcher.Form method="GET" action="https://archive-api.open-meteo.com/v1/archive?latitude=52.52&longitude=13.41&daily=temperature_2m_max&timezone=America%2FNew_York&start_date=2022-01-01&end_date=2023-08-30&temperature_unit=fahrenheit" />; | ||
|
||
// // fetcher.load(href) | ||
|
||
// useEffect(() => { | ||
// // fetcher.submit(data, options); | ||
// fetcher.load(href); | ||
// }, []); | ||
|
||
// // // build UI with these | ||
// // fetcher.state; | ||
// // fetcher.formMethod; | ||
// // fetcher.formAction; | ||
// // fetcher.formData; | ||
// // fetcher.formEncType; | ||
// // fetcher.data; | ||
// return ( | ||
// <div>{ fetcher.data }</div> | ||
// ) | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters