Directory

← Back

apod-request

Simple Polymer 2.0 element for integrating with NASA's Astromony Picture of the Date API

Author

Contributors

Rating

[ This description is mirrored from README.md at github.com/gthmb/apod-request on 2019-05-22 ]

Published on webcomponents.org

<apod-request>

Simple Polymer 2.0 element for integrating with NASA's Astromony Picture of the Date API

<!-- the tag -->
<apod-request id="myRequest" api-key="my-nasa-api-key"></apod-request>

<!-- example handling -->
<script>
  const request = document.querySelector('#myRequest'),
  results = document.querySelector("#results");

  request.addEventListener('data-changed', (evt) => {
    results.innerHTML = JSON.stringify(req.data, null, 2);
  });

  request.addEventListener('request-error', (evt) => {
    results.innerHTML = JSON.stringify(evt.detail, null, 2);
  });
</script>

Default usage

<apod-request api-key="my-nasa-api-key"></apod-request>
<!-- to listen for an event -->
<script>
    const request = document.querySelector('apod-request');
    request.addEventListener('data-changed', (data) => {
        console.log(data.detail.url);
        ...
    }
</script>

Compatibility

(Loading compatibility data...)

Was this helpful? Need more help?
Leave a comment or a question below. You can also join the chat on Discord or ask questions on StackOverflow.

Version

Dependencies

Polymer/polymer#^2.0.0

Released
2017-09-11
Maturity
TESTED
License
Other

Compatibility

Framework
Polymer 2.0+
Browser
Browser Independent
Online