Skip to content

Commit edb0693

Browse files
committed
Changed solution to 11
1 parent 6d591dd commit edb0693

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/02-passing-type-arguments/11-data-fetcher.solution.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import { expect, it } from "vitest";
22
import { Equal, Expect } from "../helpers/type-utils";
33

4-
const fetchData = async <TResult>(url: string): Promise<TResult> => {
5-
const data = await fetch(url).then((response) => response.json());
4+
const fetchData = async <TData>(url: string) => {
5+
let data: TData = await fetch(url).then((response) => response.json());
6+
67
return data;
78
};
89

910
it("Should fetch data from an API", async () => {
1011
const data = await fetchData<{ name: string }>(
11-
"https://swapi.dev/api/people/1",
12+
"https://swapi.dev/api/people/1"
1213
);
1314
expect(data.name).toEqual("Luke Skywalker");
1415

0 commit comments

Comments
 (0)