Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Oct 30, 2024
2 parents a2f3b46 + 8190d27 commit f6e9974
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/routes/guides/fetching-data.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ When there is a change in the source signal, an internal fetch process is trigge
```jsx
import { createSignal, createResource, Switch, Match, Show } from "solid-js";

const fetchUser = async (id) =>
{
const fetchUser = async (id) => {
const response = await fetch(`https://swapi.dev/api/people/${id}/`);
return response.json();
}
Expand Down Expand Up @@ -63,7 +62,6 @@ function App() {
<div>{JSON.stringify(user())}</div>
</Match>
</Switch>

</div>
);
}
Expand Down Expand Up @@ -91,7 +89,7 @@ import { createSignal, createResource, Switch, Match, Suspense } from "solid-js"
const fetchUser = async (id) => {
const response = await fetch(`https://swapi.dev/api/people/${id}/`);
return response.json();
}
}

function App() {
const [userId, setUserId] = createSignal();
Expand All @@ -106,7 +104,6 @@ function App() {
onInput={(e) => setUserId(e.currentTarget.value)}
/>
<Suspense fallback={<div>Loading...</div>}>

<Switch>
<Match when={user.error}>
<span>Error: {user.error.message}</span>
Expand Down Expand Up @@ -152,15 +149,19 @@ function TodoList() {
<>
<ul>
<For each={tasks()}>
{task => (
{(task) => (
<li>{task.name}</li>
)}
</For>
</ul>
<button onClick={() => {
mutate((todos) => [...todos, "do new task"]) // add todo for user
// make a call to send to database
}}>Add Task</button>
<button
onClick={() => {
mutate((todos) => [...todos, "do new task"]); // add todo for user
// make a call to send to database
}}
>
Add Task
</button>
</>
);
}
Expand Down

0 comments on commit f6e9974

Please sign in to comment.