How to use the fromJSON function from tough-cookie
Find comprehensive JavaScript tough-cookie.fromJSON code examples handpicked from public code repositorys.
149 150 151 152 153 154 155 156 157 158
var data = fs.readFileSync(filePath, 'utf8'); var dataJson = data ? JSON.parse(data) : null; for(var domainName in dataJson) { for(var pathName in dataJson[domainName]) { for(var cookieName in dataJson[domainName][pathName]) { dataJson[domainName][pathName][cookieName] = tough.fromJSON(JSON.stringify(dataJson[domainName][pathName][cookieName])); } } } cb(dataJson);
38
0
2
33 34 35 36 37 38 39 40 41
findCookie(domain, path, key, cb) { return redisClient.get(this.id, (err, data) => { if (err) return cb(err); const parsed = JSON.parse(data); const value = tough.fromJSON(_.get(parsed, [domain, path, key], null)); return cb(err, value); }); }
0
1
1
+ 3 other calls in file
GitHub: herlon214/phantom2jar
3 4 5 6 7 8 9 10 11 12
module.exports = async (instance) => { let cookies = await instance.cookies() let cookiejar = new tough.CookieJar() await each(cookies, async (cookie) => { let parsed = tough.fromJSON({ key: cookie.name, value: cookie.value, expires: cookie.expires, path: cookie.path,
0
0
1
tough-cookie.CookieJar is the most popular function in tough-cookie (171 examples)