Fake Fetch
interface Callback {
(n: number): void
}
const getRandom = (callback: Callback) => {
setTimeout(() => {
callback(Math.floor(Math.random() * 100))
},1000);
}
getRandom((n) => {
console.log(`The number was ${n}`);
});Laatst bijgewerkt