Search code examples
dartoperator-keywordvoid

The operator '[]'


app.post('/signup', (req, res) async {
    var body = await req.parseBody();

    var name = body['name'];
    var email = body['email'];
    var phone = body['phone'];
    var pass = body['pass'];
    var image = body['image'];
  });

enter image description here

21:21: Error: The operator '[]' isn't defined for the class 'void'. Try correcting the operator to an existing operator, or defining a '[]' operator.


Solution

  • I suppose you are using Angel, so try this:

    await req.parseBody();
    
    var name = req.bodyAsMap['name'];