import useSWR from "swr"; import { BiError } from "react-icons/bi"; 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}` ); if (error) { return (
API Error
); } if (!data) { return
; } if (data.error) { return
; } return (
{options.units === "metric" ? data.current.temp_c : data.current.temp_f}° {data.current.condition.text}
); }