I solved it by putting j in the function. Why has the compile a problem when it 
is outside of the proc? 
    
    
    import json, asynchttpserver, asyncdispatch
    
    var server = newAsyncHttpServer()
    
    proc cb(req: Request) {.async.} =
      var j = %* {
        "test": 1,
        "test2": "42",
      }
      await req.respond(Http200, j.pretty())
    
    waitFor server.serve(Port(8080), cb)
    

Reply via email to