0đź‘Ť
You can do this:
1. Create a Promise
var promise = new Promise(function (resolve, reject) {
// do a thing, possibly async, then…
if (/* everything turned out fine */) {
resolve("Stuff worked!");
}
else {
reject(Error("It broke"));
}
});
2. Using the Promise
promise.then(function(result) {
console.log(result); // "Stuff worked!"
}, function(err) {
console.log(err); // Error: "It broke"
});
I hope be useful!
- [Vuejs]-How could I loop through an array and return the values ​dynamically?
- [Vuejs]-How to change data due to selected value in select Vue?
Source:stackexchange.com