This is a treasury.io client for JavaScript. It can return a csv
or a json
response depending on whether you pass either string as the second argument..
npm install --save treasuryio
var treasuryio = require('treasuryio')
treasuryio('SELECT * FROM t1 LIMIT 10', 'json', function (err, response) {
if (err) {
console.log(err)
}
console.log(response)
})
var treasuryio = require('treasuryio')
treasuryio('SELECT * FROM t1 LIMIT 10', 'csv', function (err, response) {
if (err) {
console.log(err)
}
console.log(response)
})
The usage is exactly the same in the browser except you don't need the line var treasuryio = require('treasuryio')
. The only catch is you need to load the dsv module in your HTML like so:
<script src="dsv.min.js"></script>
You can grab copy this file from here.
To test that it works in the browser, open this page.
You should see the first ten rows of of t1
, Operating Cash Balance.
To test that it works in node, run
npm install
npm test
It should print the first ten rows from t1
, "Operating Cash Balance" as csv and json.