Typescript, Generics, Polymorphism.
Use a generic function with a constraint that T must extend a non-empty object const fetchData = async<T extends object>(url: string): Promise<ApiResponse<T>> => { try { const response = await fetch(url); const data: T = await response.json(); return { data: data, error: null }; } catch (error) {