Vapor: Vapor 3.1.2 cannot get value from request

Created on 23 Mar 2018  路  3Comments  路  Source: vapor/vapor

Hi all,
I try to test vapor 3 branch beta but got the error when try to get value from get request. The snippet code and the error like the image below:
Even I get the username by the code let username = try req.parameter(String.self) OR let username = try request.parameters.next(String.self) -> still got the same error. Please help to correct me.
screen shot 2018-03-23 at 11 45 12 am

Most helpful comment

@nhatlee FYI, 3.1.2 is the version of Vapor Toolbox, not Vapor. Vapor will soon鈩笍 hit the 3.0.0 milestone, Vapor 3.1.x is quite far in the future I suppose 馃槃The versions of Toolbox and Vapor may differ as their respective development processes are mostly unrelated to each other.

All 3 comments

router.get("name", String.parameter) { req -> String in
    let username = try req.parameter(String.self)
    return "Hello \(username)"
}

If there are more than one line code in closure, you need to add the type of returned value.

@linqingmo: Thanks for your help

@nhatlee FYI, 3.1.2 is the version of Vapor Toolbox, not Vapor. Vapor will soon鈩笍 hit the 3.0.0 milestone, Vapor 3.1.x is quite far in the future I suppose 馃槃The versions of Toolbox and Vapor may differ as their respective development processes are mostly unrelated to each other.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Joannis picture Joannis  路  4Comments

Joannis picture Joannis  路  4Comments

olivier38070 picture olivier38070  路  3Comments

hjuraev picture hjuraev  路  3Comments

avario picture avario  路  3Comments