import useSWR from "swr"; import Icon from "./icon"; export default function Weather({ options }) { const { data, error } = useSWR( `/api/widgets/weather?lat=${options.latitude}&lon=${options.longitude}&apiKey=${options.apiKey}&duration=${options.cache}`, { revalidateOnFocus: false, revalidateOnReconnect: false, } ); if (error) { return
failed to load
; } if (!data) { return
; } if (data.error) { return
; } return (
{Math.round(data.current.temp_f)}° {data.current.condition.text}
); }