Question

Please tell me, how I can get the variables values of the GET request I do so:

{Method, Req2}       = cowboy_req:method(Req),
{FwdIPRaw, Req3}     = cowboy_req:header(<<"x-forwarded-for">>, Req2),
{ClientCookie, Req4} = cowboy_req:cookie(<<"cook">>, Req3),
{ok, GetVals, Req5}  = cowboy_req:qs_vals(Req4),
MessageId   = proplists:get_value(<<"mid">>, GetVals),
EchoName    = proplists:get_value(<<"m">>, GetVals),
{ok, Req5, State}.

But I get an error: qs_vals - undefined

Was it helpful?

Solution

For current cowboy version (0.9.0) documentation says that cowboy_req:qs_vals(Req4) returns {QsVals, Req5} where QsVals can be [] (empty list). So try 0.9.0 cowboy version and fix call {ok, GetVals, Req5} = cowboy_req:qs_vals(Req4) to {GetVals, Req5} = cowboy_req:qs_vals(Req4).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top