showing results for - "node js how to basic auth to specific urk"
Coline
24 Oct 2017
1var request = require('request')
2var username = 'fooUsername'
3var password = 'fooPassword'
4var options = {
5  url: 'http://localhost:1234/api/res/xyz',
6  auth: {
7    user: username,
8    password: password
9  }
10}
11
12request(options, function (err, res, body) {
13  if (err) {
14    console.dir(err)
15    return
16  }
17  console.dir('headers', res.headers)
18  console.dir('status code', res.statusCode)
19  console.dir(body)
20})