Back

Cloud Function Result

  • 0
  • Flutter
  • Functions
Binyamin
15 Jun, 2023, 15:59

What you do need to do is probably to jsonDecoded it.

TL;DR
User is experiencing an issue with a Cloud Function in Appwrite. They tried redeploying the function but the issue persists. Another user suggests using the `functions.createExecution` method to get the response of the function. The response will be a string that needs to be parsed. User confirms that this solution works.
dammy
15 Jun, 2023, 16:00

okay

dammy
15 Jun, 2023, 16:02
TypeScript
      if (kDebugMode) {
        final decoded = jsonDecode(response.toString());
        print(decoded.toString());
      }
    })```

no result
dammy
15 Jun, 2023, 16:03

this is on cloud function code:

TypeScript
    'areDevelopersAwesome': true,
  });```
Binyamin
15 Jun, 2023, 16:03

Do this

TypeScript
functions.createExecution(
 functionId: '[FUNCTION_ID]',
).then((response) {
 if (kDebugMode) {
   print(jsonDecode(response.response));
 }
};
dammy
15 Jun, 2023, 16:04

worked, thanks

dammy
15 Jun, 2023, 16:11

but at times, changes on cloud function does not reflect even when build is completed on console

dammy
15 Jun, 2023, 16:16

what is the solution?

Binyamin
15 Jun, 2023, 16:17

What you mean? You're deploying a new function and getting back the old one?

dammy
15 Jun, 2023, 16:17

got this: flutter: {areDevelopersAwesome: true}

and I changed the respinse on cloud

dammy
15 Jun, 2023, 16:17

yes

Binyamin
15 Jun, 2023, 16:17

What you get when you're executing it on the cloud?

safwan
15 Jun, 2023, 16:20

@dammy When you execute a function from your client app, it returns an Execution object: https://appwrite.io/docs/models/execution

If you want to get the response of the function, you can do something like this:

TypeScript
const promise = await functions.createExecution('[FUNCTION_ID]');
const response = promise.response;

Keep in mind that promise.response will be a string, that you will need to parse.

dammy
15 Jun, 2023, 16:22

got this: areDevelopersAwesome: true

And I changed it to this: 'status': "refund"

safwan
15 Jun, 2023, 16:22

did you redeploy?

Binyamin
15 Jun, 2023, 16:22

How have you deployed the new version of the function?

dammy
15 Jun, 2023, 16:22

I appreciate, sorted, am now getting response by decoding it

dammy
15 Jun, 2023, 16:23

yes, appwrite deploy function

dammy
15 Jun, 2023, 16:23

function ID is also accurate

safwan
15 Jun, 2023, 16:23

alright perfect

dammy
15 Jun, 2023, 16:23

thanks

dammy
15 Jun, 2023, 16:24
TypeScript
? Which functions would you like to deploy? automated_mobile_data (my_function_ID)
Info Deploying function automated_mobile_data ( my_function_ID )
Info Ignoring files using configuration from appwrite.json
Success Deployed automated_mobile_data ( my_function_ID)
Success Deployed 1 functions```
dammy
15 Jun, 2023, 16:29

I deliberately deleted the function from console and do a fresh deployment, same issue

dammy
15 Jun, 2023, 16:34

It just reflected, took sooooo long

I noticed that this issue is consistent with appwrite cloud

safwan
19 Jun, 2023, 07:44

what's the use-case?

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