parse token from int or str (#405)

This commit is contained in:
Ryan Koppenhaver 2021-07-01 05:33:40 -07:00 committed by GitHub
parent a859943871
commit 669aa2cd8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -36,11 +36,13 @@ proc fetchToken(): Future[Token] {.async.} =
var var
resp: string resp: string
tokNode: JsonNode
tok: string tok: string
try: try:
resp = clientPool.use(headers): await c.postContent(activate) resp = clientPool.use(headers): await c.postContent(activate)
tok = parseJson(resp)["guest_token"].getStr tokNode = parseJson(resp)["guest_token"]
tok = tokNode.getStr($(tokNode.getInt))
let time = getTime() let time = getTime()
result = Token(tok: tok, remaining: 187, reset: time + resetPeriod, result = Token(tok: tok, remaining: 187, reset: time + resetPeriod,