ckan.js test

A quick test of the library

by loleg

HTML

<script src="https://cdn.jsdelivr.net/gh/loleg/ckan.js@master/dist/ckan.bundle.js"></script>
Note: to get this to run, install something like:

https://github.com/garmeeh/local-cors-proxy

... and run a command like this:

lcp --proxyUrl https://demo.ckan.org/

... to get around the CORS restriction.

CSS

body { background: white; }

JavaScript

var client = new CKAN.Client('http://localhost:8010/proxy');
client.action('package_search', 
  {
    q: 'water'
  },
  function(err, out) {
    if (err) console.log(err);
    console.log(out);
    
    if (out.result) {
    	tt = '<ul>';
    	out.result.results.forEach(function(t) {
      	tt += '<li>' + t.title + '</li>';
      });
      document.getElementsByTagName('body')[0].innerHTML = tt + '</ul>';
    }
  }
);