2016-12-11

Fetch API via TypeScript Async

As I mentioned in my post earlier today, TypeScript 2.1 was released this past week with downlevel async support. Practically, that means that we can now use async and have it work in Internet Explorer 10 that some corporate customers need. There is also a polyfill for the fetch api that supports IE 10, so we can use that new standard too instead of jQuery ajax. ES7 Async support builds on the ES6 Promises. Chrome, Firefox, and Microsoft Edge have native support for the fetch api. It works equally well in Node.js via node-fetch. I implemented the same HTTP GET as before in a test, but with the fetch api and also made use of async.

fetch-tests.ts

It outputs the same info in about half the time for me.

output.txt

There is a pull request open to include type definitions for the fetch api standard, but for now, it is easy to save the two files locally that are in progress. Please also vote up the pull request, so that it gets attention.

install.sh