Polymer 2.0 Component Usage

iron-ajax is generally the backbone of any Polymer web app that retrieves data from an API. It’s built on top of the Promise API and should handle just about all of your network needs.

Usage in DOM

    <!-- html -->
    <iron-ajax id="getUser" 
        method="GET"
        on-response="_getUserSuccess" 
        on-error="_getUserError" 
        withCredentials="true"></iron-ajax>

Basic GET request. I like to set as the id to exactly what the call will be doing; in this case getting user data. There’s plenty of properties to take advantage of but I place emphasis on setting on-response and on-error.
Continue reading →