How does Promise + exports output values directly instead of promise objects?

a.js

// a.js
module.exports = {
    list: async () => {
        return await axios.get(getIntelligentPlatform)
    },
}

b.js

// b.js
const { list } = require("../models/meibrain")
// 
list().then(res => {
    console.log(res.data.obj)
})

I hope list in b.js file require is the requested data

Mar.03,2021

Let me tell you the conclusion directly. there is no way .

the direct output value you are talking about, in essence, only the Synchronize operation can directly output the value.

for asynchronous operations, either callback or Promise is used. Both of these values cannot be output directly.

and the only one similar to the direct output value is async .

const { list } = require('../models/meibrain')
(async()=>{
    let res = await list();
})()

async/await allows you to write asynchronously just like writing Synchronize, but it is essentially a syntax candy for Promise .

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e95e99-4ea63.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e95e99-4ea63.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?