Menu

📰
0

Reddit - Please wait for verification

Reading 0:00
15s threshold

Hello, I’m a beginner with asynchronous code, and I’m facing an issue that I haven’t been able to solve. Even after searching online, I couldn’t find a clear explanation. In the code below, I have the impression that the return inside the catch block is being ignored. The error appears almost immediately in the console (around 0.5 seconds after the request), but the if statement only runs after about 2 minutes. async function funcOne() { try { const reponse = await fetch(`URL_API`, { }); const data = await reponse.json(); return data; } catch(error) { console.log(error); return null; } } async main() { let value = await funcOne(); if(value == null) {... So I don’t understand why the flow seems to wait that long even though the error is already detected. Thanks for your help. submitted by /u/Dull_Firefighter_929 [link] [comments]

Read More