I am using Dart server and using Shelf_router. The route is configured as follows. The payroll api is mounted as follows:
app.mount('/payroll/', PayrollApi(db).router);
The PayrollApi has the following:
router.get('/employer/<erId>/frequency/<frequency>', erPayrollApi2);
The erPayrollApi2 functions is as follows:
Future erPayrollApi2(shelf.Request req) async {
var erId = req.params['erId'];
var frequency = req.params['frequency'];
print(erId);
print(frequency);
shelf.Response.ok('Got message: f: $frequency, erId: $erId');
}
Sending the following URL using Postman:
https://localhost:843/apyroll/employer/<er100>/frequency/<Weekly>
I get the following error:
Exception has occurred. X
NoSuchMethodError (NoSuchMethodError: Closure call with mismatched arguments:
function *PayrollApi.erPayrollApi2
Receiver: Closure: (Request) => Future<dynamic> from Function
*erPayrollApi2": Tried calling: PayrollApi.erPayrollApiZ(Instance of "Request" "%3Cer100%3E" "%3CWeekly%3E") Found: PayrollApi.erPayrollApiZ(Request) => Future)
I am seeing the parameters 'er100' and 'Weekly' but stops shot of calling my function erPayrolApi2.
Changes written in comments above fixed the problem