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
- How to Avoid Double Requests in function...
I'm currently using Appwrite's `functions.createExecution` in my project. I want to avoid double requests when multiple actions (like searching or pagination) a...
- Send Email Verification With REST
I am using REST to create a user on the server side after receiving form data from the client. After the account is successfully created i wanted to send the v...
- Use different email hosts for different ...
Hello, I have 2 projects and i want to be able to set up email templates in the projects. Both projects will have different email host configurations. I see ...