编辑代码


function fun1(id) {
    return new Promise(function (resolve, reject) {
        setTimeout(function () {
            id = id+1
            resolve(id);
        }, 1000)
        console.log('fun1 promise init');
    }).then(res => {
        console.log(res);
        reject()
    });
}


function fun2(id) {
    debugger
    id = id + fun1(id);

    return new Promise(function (resolve, reject) {
        setTimeout(function () {
            resolve(id);
        }, 1000)
        console.log('fun2 promise init');
    }).then(res => {
        console.log(res);
        reject()
    });
}
console.log(fun2(2));