Skip to content

Cleaner solution of exercise 14 #36

@qianzhong516

Description

@qianzhong516

It works by using generic types.

const genericFetch = <T>(url: string, schema: z.ZodSchema<T>) => {
  return fetch(url)
    .then((res) => res.json())
    .then((result) => schema.parse(result));
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions