Created
March 12, 2019 14:29
-
-
Save mohammed-ali-1/adb947050211c6011e0783084117fe4a to your computer and use it in GitHub Desktop.
OpenWhisk web action that returns the latest ten entries to the readings database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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