Back

Unable to run function in a background after a new update

  • 0
  • Functions
RAKU
29 Sep, 2023, 18:35

Hello,

I have created a function that I want to run in the background.

I am using Postman to invoke a function.

Before the last Appwrite update, I was using a key "async" with a value set to true in the JSON body

Previous JSON:

TypeScript
{
"data": {/*Custom data*/}
"async": true
}

But now I don't know how and where to set the async to true.

Can someone please help me?

Thanks.

TL;DR
User is unable to run a function in the background after a new update. They tried running the function using a generated domain by Appwrite, but the async feature isn't working. They have tried different ways of sending data, but it still does not run in the background. They are unsure of how to set the async option when making a request using Postman or JavaScript fetch. The support suggests checking the API documentation for the updated method to set the async option. Solution: Refer to the updated API documentation for setting the async option.
RAKU
29 Sep, 2023, 18:55

Hi Steven,

Thanks for your response.

Yes, I have checked it already. However in Postman or when sending HTTPS fetch request using js, how can I set async?

Example code:

TypeScript
const url = "<Appwrite EndPoint>";
const data = {
  key1: 'value1',
  key2: 'value2'
}
const options = {
    method: 'POST',
    headers: {/* Required headers */ },
    body: JSON.stringify(data),
  };

  const res = await fetch(url, options);

In the code above, where to add the async option? (in header, body??)

Drake
29 Sep, 2023, 19:20

don't you see the example HTTP request in the docs i linked?

RAKU
29 Sep, 2023, 20:36

I can see it and Its not working 😦

Drake
29 Sep, 2023, 21:00

What are you doing?

RAKU
29 Sep, 2023, 21:29

I tried to send data like this

TypeScript
{
     "authKey":"<WP AuthKey>",
     "url":"<WP URL>",
     "type":"<WP Type>",
     "status":"<WP Status>",
     "category":"<WP Category>",
     "tag":"<WP Tag>"
}

and This

TypeScript
{
  "body": {
       "authKey":"<WP AuthKey>",
       "url":"<WP URL>",
       "type":"<WP Type>",
       "status":"<WP Status>",
       "category":"<WP Category>",
       "tag":"<WP Tag>"
    },
  "async": false,
  "path": "[PATH]",
  "method": "GET",
  "headers": {}
}

Its working perfectly but both time its not running in the background...

Drake
29 Sep, 2023, 22:32

the second one is correct....and you need to set async to true to make it execute in the background

RAKU
30 Sep, 2023, 01:56

I tried, still do not running in background

Drake
30 Sep, 2023, 02:27

What's your code exactly? What is going on?

Btw, body still needs to be a string.

RAKU
1 Oct, 2023, 01:17

Hi Steven,

I tried to run the function again with a URL like this: "https://cloud.appwrite.io/v1/functions/[Function ID]/executions/" and it's working perfectly.

However when making a request using a generated domain by appwrite, the async feature isn't working.

Why? Do generated domains not support async???

Drake
1 Oct, 2023, 02:28

Yes correct, that's expected.

RAKU
1 Oct, 2023, 02:30

Ok. Thanks for the help 🙂

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