Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Should all API calls be asynchronous in React?

When making API calls in React, should they all be asynchronous?

Is this a one-size-fits-all answer, or is this scenario-based? If so, what are some good examples of where to use async calls, and where not to use them?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The only way to perform sync API calls is by using XMLHttpRequest in a very particular fashion which is deprecated.

More modern APIs like fetch do not support sync requests even as 1st April joke.

So, yes, it’s a very good idea to keep your API requests async, always.

Sync requests are problematic, make your app perform really bad & are just silly.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading