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
- Invalid query: Attribute not found in sc...
Hiya. I'm trying to use the REST API with documents and doing a simple select with query: https://<mydomain>/v1/databases/<database>/collections/<collection>/d...
- Deploying Function fails after several d...
I get the below issue on deploying to self hosted appwrite 1.8.0 functions, restarting the docker compose, or waiting a while, fixes it but is annoying. Any ide...
- Hosted a webite on appwrite 2 days ago, ...
I dont really know why its down, everything looks fine, the deployments and all