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

[ 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>

Install

Link to this version
TestedReleased 11 September 2017Other
Framework Support
Polymer 2.0+
Browser Compatibility
Install with
Release notes - Version 0.0.7

Dependencies

Polymer/polymer#^2.0.0