Tip 45 Make Simple AJAX Calls with Fetch

In this tip, you’ll learn how to retrieve remote data using fetch().

If you do any significant JavaScript app development, you’ll have to interact with APIs. With APIs, you can get current information and update single elements without a page refresh. In short, you can create very fast applications that behave like native software.

Single-page web apps are part of the reason why JavaScript is so popular, but getting data with AJAX—Asynchronous JavaScript And XML—used to be a hassle. It was such a hassle that most developers used a library, usually jQuery, to to reduce the complexity. You can see the documentation on the Mozilla Developer Network.[46] It’s not easy stuff.

Now, there’s a much simpler ...

Get Simplifying JavaScript now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.