Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
OpenWhisk web action that returns the latest ten entries to the readings database
function action(args) {
var request = require('sync-request');
var res = request(
'GET',
'http://COUCHDB_HOST:COUCHDB_PORT/readings/_all_docs?limit=10&include_docs=true&ascending=true'
);
var readings = JSON.parse(res.getBody().toString()).rows.map(elem => elem.doc.reading);
return {
body: readings
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.