Return [[PromiseResult]] in vue js [duplicate] - javascript

This question already has answers here:
How can I access the value of a promise?
(14 answers)
Is there a way to save [[Promise Result]] as a variable? [duplicate]
(3 answers)
Is it impossible to get the [[PromiseValue]] from a Promise object without using the Promise object's then method? [duplicate]
(1 answer)
Closed 2 years ago.
How to return [[PromiseResult]] guys, please help thankss
i use vue js and laravel

You can get that result by adding then method to the Promise. For example:
new Promise((resolve, reject) => resolve('success')).then(res => console.log(res))
This code will log your [[PromiseResult]] object.

Related

this keyword in an object i am returning from a function is undefined [duplicate]

This question already has answers here:
Methods in ES6 objects: using arrow functions
(6 answers)
Arrow Function in Object Literal [duplicate]
(1 answer)
Closed 24 days ago.
image showing the function i created
the hello function of the returned object logs out undefined, instead of reference to the reply object or the returned object and I don't know why
I haven't really tried anything.

Why does Chrome console return Promise object from .then() instead of the resolved value? [duplicate]

This question already has answers here:
Why does Promise.prototype.then always return promises?
(2 answers)
How can I access the value of a promise?
(14 answers)
Does then() really return a promise in all cases? [duplicate]
(2 answers)
promise.then() returns Promise { <pending> } [duplicate]
(3 answers)
Closed 7 months ago.
I'm trying to better understand promises and async code in Javascript.
In doing so, I wrote the following, simple async function in the Chrome console:
const myAsync = async() => 10;
As expected, myAsync returns a promise, but when I call .then() (i.e. myAsync().then(res => res)), then console displays Promise{<fulfilled>: 10}. The promise is clearly fulfilled, but I would expect it to display, simply, the value 10.
Interestingly, if I modify the body of my call to .then() to res => alert(res), the alert displays what I expect, just 10.

How to use biri in vanilla js? [duplicate]

This question already has answers here:
Async function returning promise, instead of value
(3 answers)
How do I return the response from an asynchronous call?
(41 answers)
Closed 9 months ago.
I am trying to use biri on my browser (vanilla javascript) I am following the tutorial but I have an error saying I can't use the await statement.
I've tried to create a async function to return the uniqueId but it return a promise object. I am struggle since more than a hour to get this uniqueId.
Any suggestion ?

Javascript - Variable loose it's value after block [duplicate]

This question already has answers here:
How do I return the response from an asynchronous call?
(41 answers)
Closed 2 years ago.
Can somebody explain me how to solve this problem?
let konyvSzam=0;
db.checkPeldanySzam(rentISBN,(konyv) => {
konyvSzam=konyv.Peldanyszam;
});
console.log("Nr of books");
console.log(konyvSzam);
The variable gets the value but after I check it doesn't work
Mostly our DB call works asynchrous in node js and JavaScript try to enclose db calls in promise or use async/await .

How to pass 'this' into a Promise without caching outside? [duplicate]

This question already has answers here:
How to access the correct `this` inside a callback
(13 answers)
Closed 3 years ago.
I have a variable called LangDataService.isDataReady that is a Promise wawiting to be resolved. Upon resolve some logic will happen. How can I pass this into that Promise?
LangDataService.isDataReady.then(function () {
this.modalOn()
});
I know i can cache var self_ = this; but I'm curious of other alternatives?
LangDataService.isDataReady.then(function () {
this.modalOn()
}.bind(this));

Categories