initial backend
This commit is contained in:
@@ -1,6 +1,20 @@
|
||||
import type { Component } from "solid-js";
|
||||
import { createSignal, For, onMount } from "solid-js";
|
||||
|
||||
interface Weather {
|
||||
date: string;
|
||||
temperatureC: number;
|
||||
temperatureF: number;
|
||||
summary: string;
|
||||
}
|
||||
|
||||
const App: Component = () => {
|
||||
const [weather, setWeather] = createSignal<Weather[]>([]);
|
||||
onMount(() => {
|
||||
fetch("/api/weatherforecast")
|
||||
.then((r) => r.json())
|
||||
.then(setWeather);
|
||||
});
|
||||
return (
|
||||
<div>
|
||||
<header>
|
||||
@@ -15,6 +29,15 @@ const App: Component = () => {
|
||||
Learn Solid
|
||||
</a>
|
||||
</header>
|
||||
|
||||
<For each={weather()}>
|
||||
{(item) => (
|
||||
<li>
|
||||
{item.date} - {item.temperatureC}°C / {item.temperatureF}°F -{" "}
|
||||
{item.summary}
|
||||
</li>
|
||||
)}
|
||||
</For>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
Reference in New Issue
Block a user