Parsing Request Bodies
Parsing the body
app.post('/my_form', (req, res) async {
// Parse the body, if it has not already been parsed.
await req.parseBody();
// Access fields from the body, which is the most common use case.
var userId = req.bodyAsMap['user_id'] as String;
// If the user posted a List, i.e., through JSON:
var count = req.bodyAsList.length;
// To access the body, regardless of its runtime type:
var objectBody = req.bodyAsObject as SomeType;
});Handling File Uploads
Custom Body Parsing
Last updated