
I have a appwrite function which make several(depending on situation, some where between 100 and 500) api calls to appwrite database(database.updateDocument). I want to insert a delay of 200ms between each update api call( becouse I am listening to database changes via real time channels. I want to insert delay becouse if updates are spontaneous then I can not listen to that changes and updates my UI at the frontend). I tried using setTimeOut. But it is not working as expected. How can I insert delay?

Is this JavaScript?

yes

Try something like this, First create this function
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
Then you can use it each time.
while(true){
await sleep(200);
// ... your code
}

I tried this. But it didn't work. The function is executed with in 200ms, even though my delay is 100ms between each api call.

😟

That's weird Can you try to add
console.log(+new Date());
inside the loop?

To see if there's any delays?

some how now its working. thank you

I am using react-native for developing an app. I got an error when I tried to subscribe to a channel. I resolved this by modifying file appwrite\dist\cjs\sdk.js line 187 as const cookie = JSON.parse((_a = typeof window.localStorage !== 'undefined' && window.localStorage.getItem('cookieFallback')) !== null && _a !== void 0 ? _a : '{}'); thank you

try searching <#1072905050399191082>. if you're still stuck, it's best to create a new post since this is a different topic.

All issues got resolved. Thank you
Recommended threads
- my database attribute stuck in processin...
when i created attributes in collection 3 of those attributes become "processing", and they are not updating, the worst thing is that i cant even delete them s...
- Is Quick Start for function creation wor...
I am trying to create a Node.js function using the Quick Start feature. It fails and tells me that it could not locate the package.json file. Isn't Quick Start ...
- Forever Processing Issue
I encountered an issue when creating attributes in the collections . if you create an attribute of type string for example and choose a size of 200 or 250 or a...
