AI AI Conversation Sharing

Discover and share amazing AI conversations

DALL-E 3

AI image generation model

1 conversations

Why does X happen and how to fix it?

I'm confused why my console.log('done') runs before my fetch request finishes—even though it's after the fetch call in my code. What's happening here?

Great question! This is a classic JavaScript event loop behavior. `fetch()` is asynchronous and returns a Promise, but it doesn’t block execution — so the JS engine immediately moves to the next line (`console.log('done')`) while the network request happens in the background. To wait for the response, you need to use `.then()` or `async/await`. Would you like a quick example showing both approaches?

+2 more messages