import useSWR from "swr"; import { BiError } from "react-icons/bi"; import Icon from "./icon"; export default function WeatherApi({ options }) { const { data, error } = useSWR(`/api/widgets/weather?${new URLSearchParams(options).toString()}`); if (error) { return (
API Error
); } if (!data) { return
; } if (data.error) { return
; } return (
{options.label && `${options.label}, `} {options.units === "metric" ? data.current.temp_c : data.current.temp_f}° {data.current.condition.text}
); }