Can you explain why this request is being made to localhost?
{
errno: -4078,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 443,
config: {
url: 'https:\\stackoverflow.com/users/login?ssrc=head&returnurl=https%3a%2f%2fstackoverflow.com%2f',
method: 'get',
headers: {
Accept: 'application/json, text/plain, */*',
'User-Agent': 'axios/0.19.2'
},
I'm not intentionally using a localhost in my code, but it seems that axios is making the call to a local host for some reason. The issue I am facing with testing the function seems to be related to the code snippet below:
function Scraper(url: string, login_page?: string){
if (login_page) {
var link: string = 'https:\\' + url + '/' + login_page;
}
else {
var link: string = 'https:\\' + url;
}
axios.get(link)
.then(responce => {
const html = responce.data;
const $ = cheerio.load(html);
const website_usr_field: Cheerio = $('input[type=email]');
//if ()
/*
TODO:
1) Create if statement for assigning login type variable for values.
*/
const website_pwd_field: Cheerio = $('input[type=password]');
console.log(website_usr_field);
console.log(website_pwd_field);
return website_usr_field && website_pwd_field;
}).catch(console.error);
}