-
The problem with promise
as soon as I came into contact with promise, I wrote a demo by myself. Ask .
Why my then only executes once, and how to make it execute multiple times
var test = 0;
var promise = new Promise(resolve => {
$( .btn ).on( click ,()=...
-
The question about promise
a () {
return new Promise((res, rej) => {
:
getData().then(res => {
this.data = res.data.reslut
console.log(this.data)
})
});
}
the a method is defined in vue , and the a method is ca...
-
Js chain call problem
write a chained call as follows:
new Man( lan ).sleep(3).eat( apple ).sleep(3).eat( banana );
output: hello, lan--> (pause 3s)-> lan eat apple-> (pause 3s)-> lan eat banana my code is as follows:
class Man {
constructor(name) {
th...
-
Various implementations of promise maintain an array _ deferreds that holds the callback function set registered by the then method. When will this array reach 2 items?
I have reviewed articles of various promise implementations, all of which indicate that it is necessary to maintain a _ deferreds to save the callback function set information registered by the then method, and some implementations maintain onResolve...
-
About the problem of asynchronous login in WeChat Mini Programs? The problem of File execution order and promise problem
at present, I have written the login operation in app.js. After obtaining Wechat s code, I obtain the authentication access-token from my own server. the code is as follows
app.js
onLaunch: function () {
wx.login({
success: ...
-
How Promise does not return the promise object, but directly returns the value of resolve
functiong getPromise(){
return Promise.resolve( something );
}
let getSomething = async function(){
let a = await getPromise();
return a;
}
The async function returns a promise object, so there is no way to return a non-promise ob...
-
What's the difference between using reject and return reject in Promise's internal functions
can be run in Chrome. The program details are shown below:
will the current task queue be rolled back to the status of the Project sibling as soon as you execute reject,?
...
-
How do you loop through an asynchronous method in nodejs?
perPageFiles = filenames.slice(articleIndex, articleIndex + perPage);
perPageFiles.forEach(function(filename, index) {
fs.readFile(fileDirectory + filename + .md , utf-8 , function(err, data) {
if (err) throw err;
perPageDatas[index].arti...
-
The data of node.js nested query is lost after json.stringify?
Database query
function query(sql) {
return new promise((resolve, reject) => {
pool.getConnection(function (err, conn) {
if (err) {
reject(err);
} else {
conn.query(sql, function (e...
-
A doubt in some promise polyfill
as shown in the figure above, what is not clear is: why then uses dot syntax, while catch and finally use [] syntax because catch and finally are keywords in js? I don t know what I don t know about this.
this is the github address of this polyfi...
-
What is the difference between the exception handling method of then in Promise and catch?
Both then and catch in promise can handle exceptions, so what s the difference between them in handling exceptions?
Promise.reject( error ).then(()=> {}, val=> {
console.log(val);
});
Promise.reject( error ).catch(val=> {
console...
-
How to deal with the situation when both interfaces return and then operate again? what are the solutions?
fetch( http: 10.3.134.173 jsonp-test data dish_getbypage.php?start=1 ,
).then((response)=>
response.json()
).then((res)=>{
console.log(res[0].name);
});
fetch( http: 10.3.134.173 jsonp-test data dish_getbypage.php?s...
-
How to attach Promise? to an image upload plug-in that needs to be initialized
function loadUploadFn() {
return new Promise(function(resolve, reject) {
var len = 0;
** *
var uploadListIns = $upload.render({
elem: -sharpuploadBtn ,
url: .. accountManager uploadWechatCod...
-
The Promise.err function needs its own active reject (Promise. The default return is resolve to the next level.)
the return of err and catch does not default to reject.
new Promise((resolve, reject) => {
setTimeout(() => {
if (0) {
resolve(10)
} else {
reject(11)
}
}, 0)
...
-
The question of Promise resolve
how to reset resolve or Promise after the first resolve so that the next resolve has output
I am writing login operations, and sometimes I encounter login failures. You need to reset resolve or Promise, so that you can have resolve when you initiate a...
-
The difference between the execution order of bluebird and native Promise for then
when using bluebird and nodejs native Promise to execute the following code, the order of execution is somewhat different. What is the reason for this?
**
* bluebird, 2 3 5 6 1 4
* Promise 2 3 5 6 4 1
*
var Promise = require("bluebird"...
-
When the then method returns a new Promise instance. The catch method cannot catch the error of the new instance
function loadImageAsync(url) {
return new Promise(function(resolve, reject) {
throw new Error( BUG FOREVER )
const image = new Image();
image.onload = function() {
resolve(image);
};
image.o...
-
How to enter error handling after three errors in promise handling asynchrony?
encountered an interview question, usually after an asynchronous operation error will enter. Catch (), now has to enter after three errors, how to achieve this. ...
-
How does the second interface of promise use the data returned by the first interface?
the second interface uses the data returned by the first interface name , and then splices it without promise.all or global variables. Solve?
function ajax(url,datas){
return new Promise((resolve,reject) => {
$.ajax({...
-
About the pointing problem of this in Promise?
< H1 > Code < H1 >
undefined
(node:5784) UnhandledPromiseRejectionWarning: TypeError: Cannot read property name of undefined
at say (D: NodeJS Test test2.js:18:22)
...