Skip to content

Instantly share code, notes, and snippets.

View dumboluzz's full-sized avatar

Vincent Stuber dumboluzz

View GitHub Profile
// time is the simulated fetch response time in milliseconds
const fakeFetch = (result, time) => {
return new Promise((resolve) => {
setTimeout(() => {
resolve(result);
}, time);
});
};
const getRandom = (min, max) => {
// time is the simulated fetch response time in milliseconds
const fakeFetch = (result, time) => {
return new Promise((resolve) => {
setTimeout(() => {
resolve(result);
}, time);
});
};
const getRandom = (min, max) => {
await (async () => {
try {
const userRes = await fetch(`/api/loggedInUser`);
const user = await userRes.json();
if (!user?.id) {
throw new Error(`No user id found`);
}
const responses = await Promise.all([