Answer the question
In order to leave comments, you need to log in
How to call a variable from a custom module in Node.js?
Good afternoon!
foo.js
const needle = require('needle');
function fnCallBack(error, response) {
module.exports.cookie = response.cookies;
}
function getCookie(fn=fnCallBack) {
let url = 'http://metodkabi.net.ru/index.php?id=mod&op=user&ts=glavn';
let identity = 'id_tek=glavn&username=aysien&password=aysien';
let options = {
headers: {
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'en-US,en;q=0.5',
'Content-Type': 'application/x-www-form-urlencoded',
'Host': 'metodkabi.net.ru',
'Origin': 'http://metodkabi.net.ru',
'Referer': 'http://metodkabi.net.ru/',
'User-Agent': 'Mozilla/5.0 (Android 9; Mobile; rv:76.0) Gecko/76.0 Firefox/76.0'
}
};
needle.post(url, identity, options, fn);
}
getCookie();
const get = require("./foo");
console.log(get.cookie);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question