| 423 | }; |
| 424 | |
| 425 | function runSession(method, data, cb) { |
| 426 | const opts = plugin.makeOpts(config.sys.urls.session); |
| 427 | opts.json = true; |
| 428 | opts.method = method; |
| 429 | opts.body = data; |
| 430 | |
| 431 | const spin = h.spin('Waiting session result'); |
| 432 | request(opts, function(e, resp, body) { |
| 433 | spin.stop(); |
| 434 | e = plugin.checkError(e, resp, 200); |
| 435 | if (e && e.statusCode === 302) e = session.errors.EXPIRED; |
| 436 | |
| 437 | return e ? cb(e) : cb(null, body.sessions); |
| 438 | }); |
| 439 | } |
| 440 | |
| 441 | plugin.getSessions = function(cb) { |
| 442 | log.debug('running leetcode.getSessions'); |