How to reverse the requested parameters in the method

getCommonItem(value) {
    // api.commonItem 
   return api.commonItem({value: value}).then(res => {
      console.log("",res.data.name)
      return Promise.resolve(res.data.name)
   })
},

where to call

clipboard.png

clipboard.png

clipboard.png

how can I correctly return to the undergraduate or the masses I want?

Mar.16,2021

getCommonItem(value) {
   return api.commonItem({value: value}).then(res => {
      this.name = res.data.name
   })
},
<span>{{name}}</span>

there is no need to nest another layer.

getCommonItem(value) {
    // api.commonItem 
   return api.commonItem({value: value})
},

the getCommonItem method you write returns a promise object. So what is displayed on the interface is an object

promise can only pass values, but cannot return values

commonItem written by yourself do not return Promise


if you want to make minimal changes, you'd better use async await

to visually observe this one.

haven't tried whether this is feasible, you can try

async getCommonItem(value) {
    // api.commonItem 
   return await api.commonItem({value: value}).then(res => {
      console.log("",res.data.name)
      return Promise.resolve(res.data.name)
   })
}
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-1b36884-2c027.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-1b36884-2c027.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?