September 2018
Intermediate to advanced
398 pages
9h 43m
English
In the previous code, the for comprehension retrieves the products from the database and converts them to JSON. We are already familiar with this kind of syntax, but what about Action.async and Ok()?
In Play, all of the Action elements are asynchronous. The expected return of an Action is a status, which represents the HTTP status code (OK() = 200 OK, Created() = 201 CREATED, and so on).
As you may have noticed, the return type of the for comprehension is a status wrapped in Future. The Action.async helper function allows us to create an asynchronous Action from this Future.
Read now
Unlock full access