
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
- Creating a relationship with nested obje...
{ "data": { "name": "DiDi", "type": "Software Development", "userJobs": [{ "$id": "68cbf1e2003612fb13ca", "j...
- Realtime integration with SSR auth
Hey, I have a nextjs website with SSR auth, works great. I use a session client for user verification and an admin client with API key. Both is used with node-...
- Adding "name" column to table creates 2-...
As stated, im adding the "name" column to one table, it adds 4 duplicates. In another table it adds 3 duplicates, and when I delete 1 of them, all duplucates di...
