Back

[dart] context.req.body provides with a "prefs":[] instead of "prefs":{}

  • 0
  • Functions
Shiba
25 Feb, 2024, 00:37

final User user = User.fromMap(context.req.body );

TypeScript
type 'List<dynamic>' is not a subtype of type 'Map<String, dynamic>'
#0      new User.fromMap (package:dart_appwrite/src/models/user.dart:93)
#1      main (package:starter_template/main.dart:14)
#2      action.<anonymous closure> (file:///usr/local/server/src/server.dart:114)
#3      _rootRun (dart:async/zone.dart:1399)
TypeScript

{"$id":"65da8663ee6b6e2802ec", "25T00:14:28.175 00:00","email":"anika-von@pollich.info","phone":"","emailVerification":false,"phoneVerification":false,"prefs":[],"accessedAt":""}
TL;DR
Developers are encountering an issue where `context.req.body` returns a list instead of a map. The error indicates a mismatch in types. To resolve this, update the JSON input to have `"prefs":{}` instead of `"prefs":[]`.
Shiba
25 Feb, 2024, 00:42

i am on all latest packages and self hosted latest server

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more