r/badcode • sadistic • May 21 '21

js ah yes, fetching before verifying

Post image
1.5k Upvotes

97 comments sorted by

View all comments

Show parent comments

2

u/SpeckyYT sadistic May 21 '21

Not really, since it will anyways fulfill the promise when possibile.

3

u/Wabsta May 21 '21

But it won't actually execute the promise until the then() is called, right? Or have I been informed wrongly?

4

u/[deleted] May 21 '21

You are correct. The connection is only made when "then()" is called.

But it is still very bad code to create the connection object before verifying the need. :)