Polymer iron-ajax not working

lte__

I'm testing Polymer's iron-ajax calls. For this, I set up a dummy view:

<link rel="import" href="../bower_components/polymer/polymer-element.html">
<link rel="import" href="shared-styles.html">
<link rel="import" href="../bower_components/iron-flex-layout/iron-flex-layout-classes.html">

<dom-module id="my-voltage">
  <template is="auto-binding">
  <style include="shared-styles iron-flex iron-flex-alignment">
  .circle {
    display: inline-block;
    text-align:center;
    color: black;
    border-radius: 70%;
    background: #ddd;
    font-size: 30px;
    width: 110px;
    height: 110px;
    margin: 15px;
  }
  </style>
        <iron-ajax id="ajax"
                   auto
                   url="https://jsonplaceholder.typicode.com/posts/1"
                   last-response="{{data}}"
                   on-response="_onResponse"
                   handleAs="json">
        </iron-ajax>
        <div class="circle">{{data.id}}</div>
    </template>
  <script>
    class MyVoltage extends Polymer.Element {
      static get is() {
        return "my-voltage";
      }

      _onResponse() {
        setTimeout(() => this.$.ajax.generateRequest(), 500);
      }
    }
    customElements.define(MyVoltage.is, MyVoltage);
  </script>
</dom-module>

This, however, doesn't work. I want to ping the API every half a second, but it's not even loading once: I'm just getting an empty circle.enter image description here

What am I missing here? Why doesn't the API call work? Thank you!

Pascal L.

Well the first thing that comes in mind is that you forgot to import it? Depending on the code you shared you only import polymer-element, shared-style and iron-flex-layout-classes. Next thing i see is that the handleAs param must be written as handle-as since html does not care about camel cases

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Polymer iron-ajax data binding example not working

From Dev

Iron ajax not working

From Dev

Polymer iron-ajax events "on-response" and "on-error" not working on Mozilla FF

From Dev

Polymer Iron Flex Layout Classes Not Working

From Dev

Using Polymer iron-ajax in repeating template

From Dev

Setting callback on Polymer iron-ajax

From Dev

Trigger polymer iron-ajax request manually

From Dev

Polymer iron-ajax interval calls

From Dev

Notification via iron-ajax (Polymer)

From Dev

Polymer iron-ajax/iron-request won't fire

From Dev

Polymer iron-media-query not working as previous versions

From Dev

Polymer iron-media-query not working as previous versions

From Dev

Polymer dynamically created element not working (iron-scroll-threshold)

From Dev

Polymer iron-media-query not working on dom-repeat element

From Dev

Polymer 1.0: Wait for multiple iron-ajax requests to finish

From Dev

Polymer how to bind paper-input value to iron-ajax

From Dev

iron-ajax (Polymer 1.0) on-response event firing twice

From Dev

Polymer 1.0 <iron-ajax> inside of a dom-repeat

From Dev

Testing polymer 1.0 components with iron-ajax using wct

From Dev

Polymer dom-repeat and displaying result of iron-ajax call

From Dev

Polymer 1.0's iron-ajax passes nothing to script

From Dev

Testing polymer 1.0 components with iron-ajax using wct

From Dev

Cannot access Google Rest APIs with Iron-ajax in polymer

From Dev

Store returned values from the iron-ajax request in variables (Polymer)

From Dev

Polymer iron-ajax detail.response is null

From Dev

Polymer - iron-ajax - google sheets JSON data binding

From Dev

Polymer iron-list

From Dev

Polymer 1.0: Can anybody post a working example of iron-flex-layout?

From Dev

Polymer 1.0 default icon set in iron-icons not working using blaze (meteor) templating engine

Related Related

  1. 1

    Polymer iron-ajax data binding example not working

  2. 2

    Iron ajax not working

  3. 3

    Polymer iron-ajax events "on-response" and "on-error" not working on Mozilla FF

  4. 4

    Polymer Iron Flex Layout Classes Not Working

  5. 5

    Using Polymer iron-ajax in repeating template

  6. 6

    Setting callback on Polymer iron-ajax

  7. 7

    Trigger polymer iron-ajax request manually

  8. 8

    Polymer iron-ajax interval calls

  9. 9

    Notification via iron-ajax (Polymer)

  10. 10

    Polymer iron-ajax/iron-request won't fire

  11. 11

    Polymer iron-media-query not working as previous versions

  12. 12

    Polymer iron-media-query not working as previous versions

  13. 13

    Polymer dynamically created element not working (iron-scroll-threshold)

  14. 14

    Polymer iron-media-query not working on dom-repeat element

  15. 15

    Polymer 1.0: Wait for multiple iron-ajax requests to finish

  16. 16

    Polymer how to bind paper-input value to iron-ajax

  17. 17

    iron-ajax (Polymer 1.0) on-response event firing twice

  18. 18

    Polymer 1.0 <iron-ajax> inside of a dom-repeat

  19. 19

    Testing polymer 1.0 components with iron-ajax using wct

  20. 20

    Polymer dom-repeat and displaying result of iron-ajax call

  21. 21

    Polymer 1.0's iron-ajax passes nothing to script

  22. 22

    Testing polymer 1.0 components with iron-ajax using wct

  23. 23

    Cannot access Google Rest APIs with Iron-ajax in polymer

  24. 24

    Store returned values from the iron-ajax request in variables (Polymer)

  25. 25

    Polymer iron-ajax detail.response is null

  26. 26

    Polymer - iron-ajax - google sheets JSON data binding

  27. 27

    Polymer iron-list

  28. 28

    Polymer 1.0: Can anybody post a working example of iron-flex-layout?

  29. 29

    Polymer 1.0 default icon set in iron-icons not working using blaze (meteor) templating engine

HotTag

Archive