playframework - Forwarding in Play for Scala returns empty response -
the http forward below (futureresponse
function) returns empty response browser. ideas wrong and/or should at?
val request: wsrequest = ws.url("http://somehost/url2") val request2: wsrequest = request.withheaders("accept" -> "application/json") val data = json.obj( "aaa" -> some_data1, "bbb" -> some_data2 ) val futureresponse: future[jsvalue] = request2.post(data).map { response => val json= json.obj( "ccc" -> "111", "ddd" -> "222" ) json } ok(json)
when message in browser, data in response empty:
make action asynchronous , reply future[result], like:
def someaction = action.async { implicit request => val request: wsrequest = ws.url("http://somehost/url2") val request2: wsrequest = request.withheaders("accept" -> "application/json") val data = json.obj( "aaa" -> some_data1, "bbb" -> some_data2 ) val futureresponse: future[jsvalue] = request2.post(data).map { response => val json= json.obj( "ccc" -> "111", "ddd" -> "222" ) ok(json) } futureresponse }
Comments
Post a Comment