The processing of the result value returned by javascript asynchronously

clipboard.png
Boss, I want to finally get a return value. Instead of a promise, you can understand the two functions above as the asynchronous return of the request interface

.

The

async function returns a Promise object.
async the value returned by the return statement inside the function becomes the parameter of the callback function of the then method.

async function f() {
  return 'hello world';
}

f().then(v => console.log(v))
// "hello world"

const onefunc = async () => {
    return await new Promise( resolve => {
        setTimeout(()=>{
            resolve("");
        }, 1000);
    });
}

const getData = async () => {
    let data = await onefunc();
    console.log(data);
    return data;
}
getData();

clipboard.png

Menu