I am trying to store DateTime using cloud function. I sent this from client side.
taskData: {
'dueDateTime': dateTime,
'nullDueDate': false,
'willNotify': false,
'notificationDateTime': null,
},
And this is how sent the data to cloud function.
HttpsCallable callable =
FirebaseFunctions.instance.httpsCallable('updateTask');
await callable.call({
'taskID': taskID,
'authorID': authorID,
'users': users,
'taskData': taskData,
});
I am getting error and it's thrown from flutter side, I am not getting any error from cloud function.
[VERBOSE-2:ui_dart_state.cc(177)] Unhandled Exception: 'package:cloud_functions/src/https_callable.dart': Failed assertion: line 55 pos 10: 'parameter == null ||
parameter is String ||
parameter is num ||
parameter is bool': is not true.
#0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:46:39)
#1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:36:5)
#2 _assertValidParameterType
package:cloud_functions/src/https_callable.dart:55
#3 _assertValidParameterType.<anonymous closure>
package:cloud_functions/src/https_callable.dart:52
Reloaded 0 of 1208 libraries in 133ms.
Reloaded 33 of 1208 libraries in 791ms.
Reloaded 40 of 1208 libraries in 758ms.
Reloaded 40 of 1208 libraries in 695ms.
#4 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:377:8)
#5 _assertValidParameterType
package:cloud_functions/src/https_callable.dart:52
#6 _assertValidParameterType.<anonymous closure>
package:cloud_functions/src/https_callable.dart:52
#7 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:377:8)
#8 _assertValidParameterType (pac<…>
It not necessary since no error on cloud function but here is my Type Script code. If it comment the //'dueDateTime': dateTime,
then I have no issue.
const taskData = data['taskData'];
batch.update(userAssignedTaskPath, taskData);
When I used client side code to update firestore it converted DateTime to Timestamp and everything worked fine. I even tried to convert DateTime to Timestamp and sent it to the function Timestamp.fromDate(dateTime)
but didn't work.
Updated on 9 Jan 21: I found the solution here. If you wanna see the code let me know I will post. Convert date to timestamp for storing into firebase firestore in javascript