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);
fork icon38
star icon0
watch icon2

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);
  });
}
fork icon0
star icon1
watch icon1

+ 3 other calls in file

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,
fork icon0
star icon0
watch icon1