javascript - Using Digest Auth in meteorjs -
hello im working on prototype using digest authentication other server in meteor. can body please me how this? have tried , searched threads discussion using nodejs. can please me of meteor code?
var options = { host: 'http://some-api-link/', port: 3000, path: '/path', // authentication headers headers: { 'authorization': 'basic ' + new buffer(username + ':' + passw).tostring('base64') } }; //this call request = http.get(options, function(res){ var body = ""; res.on('data', function(data) { body += data; }); res.on('end', function() { console.log(body); }) res.on('error', function(e) { console.log("got error: " + e.message); }); });
why not use http
package
in console:
meteor add http
then can do:
var result = http.get( "http://some-api-link/path", {auth: 'username:password', params: {some_param: 'some value'}}); console.log(result.content); //or result.data depending on want
full docs on can do/how here: http://docs.meteor.com/#http_call
Comments
Post a Comment