Posted on Leave a comment

Fetch API – was I living on Mars?

I stumbled upon Fetch API today. It’s this simple:

fetch(url)
  .then((resp) => resp.json()) // Transform the response object into json
  .then(function(data) {
    // Do what the hell I want to do with received JSON data
    })
  })

 

Seriously! I must have been living on Mars to have not noticed it earlier. XMLHttpRequest and jQuery.ajax — time to move on, ba bye!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.