@Red I’m no expert but it seems to be an issue with your code
Is it the same code that you tested on cloud?
Same code on cloud just imported to local
This is on cloud
Can you share your code please
Please copy paste it here
I cant do anything with a screenshot
` import 'dart:async'; import 'dart:convert'; import 'dart:io'; import 'package:backoffice_shared/backoffice_shared.dart'; import 'package:dart_appwrite/dart_appwrite.dart'; import 'package:starter_template/utils/update_compensations.dart';
Future<dynamic> main(final context) async { final List payslipsData = json.decode(context.req.body)["payslips"]; final List employeeData = json.decode(context.req.body)["employees"]; final List compensationData = json.decode(context.req.body)["compensations"];
final List<PayslipModel> payslips = payslipsData.map((payslip) { return PayslipModel.fromJson(payslip); }).toList();
final List<EmployeeModel> employees = employeeData.map((employee) { return EmployeeModel.fromJson(employee); }).toList();
final List<CompensationModel> compensations = compensationData.map((employee) { return CompensationModel.fromJson(employee); }).toList();
final client = Client() .setEndpoint('https://cloud.appwrite.io/v1') .setProject(Platform.environment['APPWRITE_FUNCTION_PROJECT_ID']) .setKey(Platform.environment['APPWRITE_API_KEY']);
final Databases databases = Databases(client); final Messaging messaging = Messaging(client);
try { await updateCompensations( context: context, databases: databases, messaging: messaging, payslips: payslips, employees: employees, compensations: compensations, ); } catch (e) { context.error(e); }
return context.res.empty(); }
`
Future<dynamic> main(final context) async {
final Map<String, dynamic> body = json.decode(context.req.body);
final List payslipsData = body["payslips"] ?? [];
final List employeeData = body["employees"] ?? [];
final List compensationData = body["compensations"] ?? [];
final List<PayslipModel> payslips = payslipsData.map((payslip) {
return PayslipModel.fromJson(payslip);
}).where((payslip) => payslip != null).toList();
final List<EmployeeModel> employees = employeeData.map((employee) {
return EmployeeModel.fromJson(employee);
}).where((employee) => employee != null).toList();
final List<CompensationModel> compensations = compensationData.map((employee) {
return CompensationModel.fromJson(employee);
}).where((compensation) => compensation != null).toList();
final projectId = Platform.environment['APPWRITE_FUNCTION_PROJECT_ID'];
final apiKey = Platform.environment['APPWRITE_API_KEY'];
if (projectId == null || apiKey == null) {
throw Exception('Environment variables not set.');
}
final client = Client()
.setEndpoint('https://cloud.appwrite.io/v1')
.setProject(projectId)
.setKey(apiKey);
final Databases databases = Databases(client);
final Messaging messaging = Messaging(client);
try {
await updateCompensations(
context: context,
databases: databases,
messaging: messaging,
payslips: payslips,
employees: employees,
compensations: compensations,
);
} catch (e) {
context.error(e);
}
return context.res.empty();
}
Try this with added checks in it.
Okay let me try
Are you really sure your code is the same locally?
The error you showed us indicates that you made a typo
the method "erorr" does not exists but "error"
but in the code you showed us it seems to be correct
if they copy paste the code I gave them
it should work
I'm really confused. He does nowhere uses the method "erorr" in his code
I'm not sure if he sent the correct code
Im not sure either
@Red is it working?
Sorry I was moving now trying to test
I just imported from cloud no changes whatsoever
show us the code for updateCompensation
You are passing context there and that code snippet is missing here
Recommended threads
- Usage of the new Client() and dealing wi...
Hey guys, just a quick one - we had some web traffic the other day and it ended up bombing out - To put in perspective of how the app works, we have a Nuxt Ap...
- [Beginner] CLI --queries Syntax Error & ...
Hi everyone! I am a beginner with Appwrite and trying to use the CLI, but I'm stuck with a syntax error. Any guidance would be greatly appreciated! 🙏 **Enviro...
- Cloud function deploy stucks in processi...
Been trying for the last hours to deploy my function but for whatever reason, alwasy stuck on processing!