Hello. I am new to jsdom
My questionis What is the best practice to set cookie if using JSDOM(html, options), or JSDOM.fromURL(url, options) API ?
Assume I have the following working
JSDOM.fromURL(`
http://www.node.org/`, options).then(dom => {console.log(dom.serialize());})
Now if I change URL to something that requires authentication. I get a 401 error which ... makes sense.
What is the recommended approach to set the cookie, along with fromURL?
var cookiejar = new tough.CookieJar() or ??? var cookiejar = jsdom.createCookieJar();
var mycookie = {"key1=value1;key2=value2;...."};
let options={ runScripts: "dangerously",
resources: "usable",
cookieJar: cookiejar,
cookie: mycookie
};
I don't think either approach works. Is tough cookies proper way with latest jsdom? and should setting the cookie in options work? Any suggestion is appreciated. Thanks
Jasper