Skip to content

Commit

Permalink
Updated SWAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
mattpocock committed Jan 1, 2025
1 parent d08b400 commit d1d59e9
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/02-passing-type-arguments/11-data-fetcher.problem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const fetchData = async (url: string) => {

it("Should fetch data from an API", async () => {
const data = await fetchData<{ name: string }>(
"https://swapi.dev/api/people/1",
"https://swapi.py4e.com/api/people/1",
);
expect(data.name).toEqual("Luke Skywalker");

Expand Down
2 changes: 1 addition & 1 deletion src/02-passing-type-arguments/11-data-fetcher.solution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const fetchData = async <TData>(url: string) => {

it("Should fetch data from an API", async () => {
const data = await fetchData<{ name: string }>(
"https://swapi.dev/api/people/1"
"https://swapi.py4e.com/api/people/1"
);
expect(data.name).toEqual("Luke Skywalker");

Expand Down
4 changes: 2 additions & 2 deletions src/06-challenges/32-data-fetcher-with-warning.problem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ const fetchData = async <TResult>(url: string): Promise<TResult> => {

it("Should fetch data from an API", async () => {
const data = await fetchData<{ name: string }>(
"https://swapi.dev/api/people/1",
"https://swapi.py4e.com/api/people/1",
);
expect(data.name).toEqual("Luke Skywalker");

type tests = [Expect<Equal<typeof data, { name: string }>>];
});

it("Should force you to add a type annotation with a helpful error message", async () => {
const data = await fetchData("https://swapi.dev/api/people/1");
const data = await fetchData("https://swapi.py4e.com/api/people/1");

type tests = [
Expect<Equal<typeof data, "You must pass a type argument to fetchData">>,
Expand Down
4 changes: 2 additions & 2 deletions src/06-challenges/32-data-fetcher-with-warning.solution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ const fetchData = async <

it("Should fetch data from an API", async () => {
const data = await fetchData<{ name: string }>(
"https://swapi.dev/api/people/1"
"https://swapi.py4e.com/api/people/1"
);
expect(data.name).toEqual("Luke Skywalker");

type tests = [Expect<Equal<typeof data, { name: string }>>];
});

it("Should force you to add a type annotation", async () => {
const data = await fetchData("https://swapi.dev/api/people/1");
const data = await fetchData("https://swapi.py4e.com/api/people/1");

type tests = [
Expect<Equal<typeof data, "You must pass a type argument to fetchData">>
Expand Down

0 comments on commit d1d59e9

Please sign in to comment.