No description, website, or topics provided.
TypeScript JavaScript HTML
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
00 Simple Ajax
01 Simple Fetch Migration 02 Multiple Fetch to Typescript 2.0 Nov 1, 2016
02 Multiple Fetch


Simple set of samples that show how to work with promises + typescript.

The samples are based / using:

  • Typescript.
  • Webpack
  • Fetch.

Samples list

00 Simple promise and $ajax

Entry point, what happens if you want to stick to $ajax call but you want to get benefit of using promises?

In this sample we are going to hit the Github API perform a remote call using $AJAX and resolving / rejecting a promise depending on the response.

01 Using fetch simple case

In this sample we are going to use something more uptodate "fetch", we will use a polyfill to cover browsers that doesn't support fetch.

We are chaining promises and trapping errors using catch, more information about promises in this link

02 Waiting for multiple promises to be resolved

In this sample we are running more than one async request in parallel. We use the power of promises to wait for all of them to be completed and display a message (this could be used to, for example, display a spinner or wait for all of the promises to be completed to perform some special operation).

How to run the samples

  1. Download this repo
  2. Install NodeJS
  3. Open the command line of your choice and cd to the root directory of this repo on your machine
  4. Navigate (cd) to the subfolder where relies the sample you want to run.
  5. npm install - Installs packages (and will install as well typescript definitions)
  6. npm start - Builds the project and launch a lite web server (webpack-devserver).
  7. Open a browser and navigate to http://localhost:8080/ if your browser doesn't open automatically.

About Lemoncode

We are a team of long-term experienced freelance developers, established as a group in 2010. We specialize in Front End technologies and .NET. Click here to get more info about us.

For the LATAM/Spanish audience we are running an Online Front End Master degree, more info: