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

View file

@ -36,11 +36,13 @@ proc fetchToken(): Future[Token] {.async.} =
var
resp: string
tokNode: JsonNode
tok: string
try:
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()
result = Token(tok: tok, remaining: 187, reset: time + resetPeriod,