Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

node js how to basic auth to specific urk

var request = require('request')
var username = 'fooUsername'
var password = 'fooPassword'
var options = {
  url: 'http://localhost:1234/api/res/xyz',
  auth: {
    user: username,
    password: password
  }
}

request(options, function (err, res, body) {
  if (err) {
    console.dir(err)
    return
  }
  console.dir('headers', res.headers)
  console.dir('status code', res.statusCode)
  console.dir(body)
})
Comment

PREVIOUS NEXT
Code Example
Javascript :: chart js &php 
Javascript :: javascript remove element from array in foreach 
Javascript :: convert js to python online 
Javascript :: defined variables if null javascript 
Javascript :: plus in javascript 
Javascript :: javascript symbols 
Javascript :: recordrtc 
Javascript :: react map array 
Javascript :: Button get specific input hidden value JQuery 
Javascript :: angular 8 features 
Javascript :: dot notation vs bracket notation 
Javascript :: script refresh js 
Javascript :: how to get time zone difference date-fns 
Javascript :: polymorphism javascript 
Javascript :: how to use settimeout in react 
Javascript :: jq break line 
Javascript :: FTP download local file 
Javascript :: map function in js 
Javascript :: js select all 
Javascript :: js get elements in array from x to y 
Javascript :: is date 1 day ago javascript 
Javascript :: node js crud operation 
Javascript :: loading screen fivem js 
Javascript :: react children length 
Javascript :: using server passed values and client js together in ejs 
Javascript :: web storage api 
Javascript :: javascript promise with ajax 
Javascript :: try without catch 
Javascript :: get array element by index javascript 
Javascript :: AJAX - The XMLHttpRequest Object 
ADD CONTENT
Topic
Content
Source link
Name
4+5 =