I am new to JavaScript and with the concept of Promise. And I am doing test. I created a promise and two for loop that runs Promise for 6 times in total, and I knows when they got executed by console.log() Here’s my code and here’s how the console be like: Why is the second .then and all the .fina…
Tag: async-await
What if we do not wait for an asynchronous javascript function?
What if we do not wait for an asynchronous javascript function? As far as I know some languages like C # should not run an asynchronous function unmanaged! I wanted to know if this is also true for the JavaScript language? Answer It’s run just the same. (In fact, you never await a function, you await fo…
How do you access and store the values/properties of a “fulfilled” promise?
I’m trying to build an object that renders details of a certain planet. I use the fetch method and it returns a promise. How do I get the values from the [[PromiseResult]] object in order to populate the details in “render()”. I tried to call fetchPlanetData().then(data=>data.(any propert…
NodeJs push in array not working within the async function
Here is my code… When I’m trying to access schedule.passenger inside the async function It’s working but when trying to access outside the async function it’s not working. Answer forEach(async function will fire bunch of async functions and once array iterations are complete, the execu…
How can I put elements in Promise.all() array conditionally?
The code below is what I wrote. I know ‘await’ keyword shouldn’t be in for-loop well. So, I tried like this but the ‘result’ contains every elements from ‘userBooks’ and that’s not what I wanted. Please help this poor newbie😥 Answer Your condition to add the pro…
firebase.auth().currentUser is null at page load
I successfully check the user’s authentication state with onAuthStateChange observer and redirect the user to the profile page. However, I already want to show some user-specific data on the profile, (e.g. description). For that, I need the currentUser object to be initialized and populated, which takes…
Why does the callback hell works and the async/await doesnt? (in this particular case that i am testing)
I have this two codes (one i use callback hell and other async/await): The callback hell works as i imagined (the string logs appear lastly). Then i tried to convert the same code but with async/await, like this: Now the first await blocks the main thread while the other two keeps showing lastly. What am i do…
How to render something that is async in React?
I’m making a react app that works with a API that provides data to my App. In my data base I have data about pins on a map. I want to show the info of those pins on my react app, I want them to render. I get that information with axios and this url: http://warm-hamlet-63390.herokuapp.com/pin/list I want…
Why open link is not working inside a async handler on iPad Safari?
Here is some strange things on opening _blank link programatically. Environment: Device: iPad 14 browser: Safari latest A button is handling async await operation, and then triggering open a link as _blank target. I am not sure why it is not working. Any suggestions are welcome! Answer Browsers tend to block …
How to set up a function dynamically without calling it in javascript?
I have a function which calls multiple functions at the same time and waits until all of them are finished. It’s working as intended. It’s labeled as parallel below I’ve got an array which I want to map into a function with the param for each value in the array. However as you might imagine,…