import { useState } from 'react' import reactLogo from './assets/react.svg' import viteLogo from './assets/vite.svg' import heroImg from './assets/hero.png' import './App.css' import { api } from './api/index' function App() { const [count, setCount] = useState(0) const [weatherData, setWeatherData] = useState(null) const [weatherLoading, setWeatherLoading] = useState(false) const [weatherError, setWeatherError] = useState(null) async function fetchWeather() { setWeatherLoading(true) setWeatherError(null) try { const data = await api.wData() setWeatherData(data) } catch (e) { setWeatherError(e.message) } finally { setWeatherLoading(false) } } return ( <>
React logo Vite logo

Get started

Edit src/App.jsx and save to test HMR

{weatherError && (

错误:{weatherError}

)} {weatherData && (

{JSON.stringify(weatherData)}

)}

Documentation

Your questions, answered

Connect with us

Join the Vite community

) } export default App