there are a couple of new technologies you're going to see a lot of in this course those technologies are the fetch API and promises promises make asynchronous programming much easier the fetch API is a replacement for xml httprequest built on promises in this example we're getting a JSON file parsing it and capturing any exceptions that occur this is much simpler than writing a collection of event handlers and simplifies code reuse the key here is the venn function it takes a function reference and waits for the previous operation to complete before calling the function if any errors occur it transfers execution to the catch at the end we're going to use a lot of anonymous functions in this course you can use the same function declarations you've always used or use the new es2015 fat arrow syntax to declare a function the new syntax takes a list of parameters on the left the equals greater than arrow and a code body on the right take a moment to look at this shorthand as we will be using it frequently using fat arrow functions lets us rewrite the first example more concisely we call fetch pass the result to a function now we catch any exceptions with the second function that probably went by quickly so take a moment to try these in your browsers console they work in most modern browsers but check your favorite source for fetch and promises support open the browser's console and type in this quick fetch sample it gets index.html in the local directory and shows the result try it with and without an index.html file you can find this sample in the core technologies lab folder under 50 text let's try to sample it retrieves a JSON file just change the file name to animal stock JSON and the response decoder from text to JSON all over case this time it fetches animal JSON which is in the core technologies folder and decodes the JSON and that's it don't worry if that was by quickly we'll take a deeper dive into and promises in a bit please take a few minutes and experiment with these examples before moving on to the serviceworker
Posted from my blog with SteemPress : http://videomarketingproductreviews.com/core-technologies-enhanced/