Pergunta de entrevista da empresa Treeverse

From the coding interview- Given async/await function, how to wait 10 seconds for promise and return some informative answer if promise doesn’t return. follow up q: can you do it without the race?

Resposta da entrevista

Sigiloso

8 de nov. de 2024

Promise.race([ func, new Promise((resolve) => setTimeout(() => resolve(‘msg’), 10000) ) ]);