Inital data fetch
This commit is contained in:
@@ -1,6 +1,23 @@
|
|||||||
import React from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
|
|
||||||
|
const onWeatherFetch = async function (cb) {
|
||||||
|
const response = await fetch(
|
||||||
|
"http://api.weatherapi.com/v1/current.json?key=bfca7632f8dc4253859120435242301&q=Vienna&aqi=no",
|
||||||
|
);
|
||||||
|
const data = await response.json();
|
||||||
|
|
||||||
|
cb(data);
|
||||||
|
};
|
||||||
|
|
||||||
const App: React.FC = () => {
|
const App: React.FC = () => {
|
||||||
|
const [data, setData] = useState(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
onWeatherFetch(setData);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
console.log(data);
|
||||||
|
|
||||||
return <div className="fixed top-0 right-0 bottom-0 left-0">Hello world</div>;
|
return <div className="fixed top-0 right-0 bottom-0 left-0">Hello world</div>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user