generic for fetch solution does not work in the official playground
hazartilirot opened this issue · 0 comments
hazartilirot commented
The provided code in the video does not seem to be working.
If you take the code and paste it into Typescript playground (I have done it for you) - you will get a bunch of errors.
The solution is as following:
const fetchData = async <T>(url: string): Promise<T> => await fetch(url).then(resp => resp.json as T)