did you update sdk: >=2.19.3 <3.0.0 to sdk: >=2.17.7 <3.0.0?
yes
you main.dart should have something like this:
import 'dart:math';
import 'dart:async';
Future <void> start(final req, final res) async {
final payload =
!req.payload?.isEmpty ? req.payload :
'No payload provided. Add custom data when executing function.';
final secretKey =
req.variables['SECRET_KEY'] ??
'SECRET_KEY variable not found. You can set it in Function settings.';
final randomNumber = new Random().nextDouble();
final trigger = req.variables['APPWRITE_FUNCTION_TRIGGER'];
res.json({
'message': 'Hello from Appwrite!',
'payload': payload,
'secretKey': secretKey,
'randomNumber': randomNumber,
'trigger': trigger,
});
}
Or a simpler version
import 'dart:async';
Future <void> start(final req, final res) async {
res.json({
'message': 'Hello from Appwrite!'
});
}
Have you considerate to use Appwrite CLI?
its working now
<:appwritepeepo:902865250427215882>
thankyou @Guille
i have completed the setup
is that more easy?
Yes it's, it handles all automatically, you just run a command and it's deployed in Appwrite
Check this documentation: https://appwrite.io/docs/command-line
wat probably might be wrong here
@Guille
i am getting a curl error
are you using appwrite cloud?
yes
i fixed this
but
for this code i am getting same curl error
How to create and deploy a dart function?
I'm going to mark this as solved since the part about creating and deploying the function is solved.
[SOLVED] How to create and deploy a dart function?
Recommended threads
- Appwrite-injected variables are not avai...
I am using rust-1.83 as a runtime and try to access APPWRITE_FUNCTION_API_ENDPOINT or APPWRITE_FUNCTION_API_KEY during runtime. Both are not set during my execu...
- Functions in cloud console not works
please advise as all of my runing functions on Appwrite console was working before , but now it give this error [Invalid `headers` param: Value must be a valid...
- [SOLVED] Production down - createExecuti...
Hey, Since 1.9.6 rollout in fra (~17:00 UTC, 14 Aug), POST /v1/functions/{functionId}/executions returns a 400 whenever the body includes an empty headers ob...