http - Meteor call to Intrinio API returns data:null -


does have example of call intrinio financial data api? trying reconcile their instructions meteor chef post getting halfway there. able access data via browser , via command line not through code. first time working api of kind, appreciate suggestions.

also, understand there npm package intrinio client. i'm on meteor 1.2.1, not using npm.

i've added http package , written following in client/lib file:

getdata = function() {     http.call('get','api.intrinio.com', {         query: "/companies?ticker=aapl",         authorization: "myusername:mypassword"         },         function( error, response ) {             if(error) {                 console.log("error")                 } else {             console.log(response)             }         });     }; 

in console, returns following - i'm getting right status code data empty:

object {     statuscode: 200,     content: "<!doctype html>↵<html>↵<head>↵  <link rel="stylesh…pfinance</title>↵</head>↵<body>↵↵</body>↵</html>↵",     headers: object,     data: null } 

the intrinio instructions recommend following, seems conflict suggestion on how write call meteor:

var https = require("https");  var username = ""username"; var password = ""password"; var auth = "basic " + new buffer(username + ':' + password).tostring('base64');  var request = https.request({     method: "get",     host: "api.intrinio.com",     path: "/companies?ticker=aapl",     headers: {         "authorization": auth     } }, function(response) {     var json = "";     response.on('data', function (chunk) {         json += chunk;     });     response.on('end', function() {         var company = json.parse(json);         console.log(company);     }); });  request.end(); 

try this:

use auth parameter (instead of authorization)

the query parameter must contain query string parameters. /companies needs part of url.

just safe, specify https:// protocol in url.

http.call('get','https://api.intrinio.com/companies', {   query: "ticker=aapl",   auth: "myusername:mypassword" }, function( error, response ) {   if (error) {     console.log("error", error)       } else {     console.log(response)   } }); 

here link above code: https://github.com/intrinio/intrinio-meteor-example/blob/master/server/main.js

i hope helps! way, work intrinio. offer free chat support if need in future.


Comments

Popular posts from this blog

How to understand 2 main() functions after using uftrace to profile the C++ program? -

c# - Update a combobox from a presenter (MVP) -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -