Write blocking javascript
I have a tiny server I'm trying to fetch a bunch of files from; ~100 to fetch. I'm using JS to fetch the files using a forEach loop. Unfortunately, the ~100 requests knocks over the server. links.forEach((link) => { const…
I have a tiny server I'm trying to fetch a bunch of files from; ~100 to fetch. I'm using JS to fetch the files using a forEach loop. Unfortunately, the ~100 requests knocks over the server. links.forEach((link) => { const…
I was asked the following question in a JavaScript interview. I was unable to answer it. Please help! const printString = (string, callback) => { setTimeout(() => { console.log(string); callback(); }, Math.random() * 1000); }; Call function printString three times…
According to the MDN documentation on await: When an await is encountered in code (either in an async function or in a module), the awaited expression is executed, while all code that depends on the expression's value is paused and…
I'm using django with Telegram Bot If i need to make ORM Query, i can do it like that all_offers = await sync_to_async(Offers.objects.filter, thread_sensitive=True)( status = True, ) but not i need to make more difficult query with Q function…
I have a function and its have nested two ajax call. I want to return a value inside from second ajax call when ajax call is successed. i think because function ending but the ajaxs call still not end. But…
I have two functions in flutter. the first one is belManager.writeCharacteristic and the second one is belManager.disonnect I want to execute belManager.disonnect() after belManager.writeCharacteristic is completed. However for some reason bleManager.disonenct() is called before belManager.writeCharacteristic is completed. this is the…
Is it a good approach to make API method async? I have an API which creates user and send a verification code to user email. JWT token is generated after email is sent on user email so I have made…
Below is the simple code of Promise.all, But the output is confusing the behaviour of Promise.all. // A simple promise that resolves after a given time const timeOut = (t) => { return new Promise((resolve, reject) => { setTimeout(() =>…
I have a problem. there is a need to perform two asynchronous requests. The second is executed with the results of the first. For some reason the data is not being rendered. If I execute only the first request, then…
I am learning promises in javascript and I decided to implement a simple promise where I would set a timeout of 3 seconds and then reject the promise. Upon rejecting it, I am catching the error and displaying it in…