@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
- User ID case sensitivity
I see that through REST (and SDK as well), getting a user is not case sensitive. And even though documentation does not clearly state that it is, the wording "V...
- Any way to temporarily bypass the email ...
Hey guys, any way to bypass the email verification to use the accounts again? i need to recover some projects that due to recent changes have been stopped, and ...
- How to use Sites on selfhosted appwrite
whenever I try to create a site even with template it says 404 nginx error