I am just starting to work with JS and SQLite. And could not find any help for my specific question. I want to keep a return to use it as a foreign key in a second table. This is my function: What do I have to do so that promise does not stay undefined outside of the function? Rest of
Tag: es6-promise
Why doesn’t TypeScript enforce async/await on promise?
I have the following code. performAsyncAction performs an async action and returns Promise<Response>. In someFunction , I was surprised that TypeScript doesn’t warn about not using await on a function that returns a promise. I found a relevant linting rule that may help promise-function-async Answer It is not an error, it is intended behaviour. The Promises existed long before async/await,
Connection is not defined in oracledb
I am using the oracledb cen node.js module and when making a database connection to make a select, it returns the data but this error also appears: I do the query like this: Answer If you can use await, then you’re in an async function. If you’re in an async function, why are you using promise chains? Here’s what this
How do I initialize a default “data” value to the returned value of a callback function?
I am running into an issue being able to initialize a value on App.vue to the result of a function when that function is async. I also tried setting it to the resolution of a promise but that didn’t seem to work either. In the former case I just get an undefined value, and in the second I just get
why is async-await much slower than promises when running them together
I found out that running async-await can be much slower in some scenarios. IMO, the console.log in usingPromises should print similar results to the one in usingAwait. But in reality, I get: Total (promises): 0.25 ms Total (await): 2.065 ms Also, after the page load, if I click on ‘usingPromises’ or ‘usingAwait’ button I get similar results for each of
Why would you try-catch around a promise? Does that catch the promise’s error?
I stumbled upon some code that looked off to me: If some somePromise() fails, would this not get caught, and the app would crash? Does this try-catch even do anything? Should be this, correct?: Answer TL;DR – If a function that returns a promise throws an exception before returning the promise then that exception would have to be caught in
Why do both Promise’s then & catch callbacks get called?
I have the following code and when it’s executed, it returns both “rejected” and “success”: Could anyone explain why success is logged? Answer The then callback gets called because the catch callback is before it, not after. The rejection has already been handled by catch. If you change the the order (i.e. (promise.then(…).catch(…))), the then callback won’t be executed. MDN
How to retrieve all posts of a user via Facebook Graph API using promises and recursion?
I am currently developing a web app which uses the Facebook Graph API. What I would like to achieve is to get all posts of a user. However, this is not that easy since I have to paginate the results. At the moment I am struggeling with promises. What I try to achieve is to fill an array with the
How to pass parameter to a promise function
this might seem a silly question but I am a newbie in this topic. I am working on promises on node js. And I want to pass parameter to a promise function. However I could not figure it out. and the function is something like Answer Wrap your Promise inside a function or it will start to do its job
How can I fetch an array of URLs with Promise.all?
If I have an array of urls: And I want to build an object that looks like this: I’ve been trying to learn to do this with fetch, which of course returns Promises. Some things I’ve tried that don’t work: This doesn’t look right, and in any case it doesn’t work — I don’t end up with an array [‘one’,