문제

I am trying to fetch a rss feed from our staging site and at present it has htpasswd security on it.

I have tied using the format:

http://username:password@url.com

This works on the browser but when I try to do this with nodejs it fails.

Could you tell me what is the right way to do this with node.js.

도움이 되었습니까?

해결책

app.js

var request = require('request');

request.get('http://url.com', callback).auth('username', 'password', false);

function callback(err, response, body) {
  console.log(body);
}

terminal:

npm install request
node app.js

document: https://github.com/mikeal/request

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top