Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getPrice(today, callback){
- var url;
- var username = 'some username';
- var password = 'some password';
- url = 'some url'+ createTimeString(today);
- var options = {
- host: 'some host',
- path: url,
- auth: username + ':' + password
- };
- https.get(options, function(res){
- res.setEncoding('utf8');
- var body = '';
- res.on('data', function(d) {
- body += d;
- var obj = JSON.parse(body);
- console.log(obj);
- callback(obj.Entries[0].EntryPx);
- });
- res.on("end", function () {
- //console.log(body);
- });
- res.on('error', function(e) {
- context.fail("Got error: " + e.message);
- });
- });
- }
- getPrice(today, function(result) {
- curr_price = result;
- speechOutput = "The curr price is " + curr_price.toString();
- //rest of code
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement