首页 文章

当我只有用户代码时如何获取用户全名?

提问于
浏览
0
static getEmployeeByCode(code) {
        if (isMock) {
            return new Promise((resolve) => {
                setTimeout(() => {
                    resolve(Object.assign({}, employeeMock));
                });
            });
        }
        return axios.get(`${EmployeesUrl}/${code}`)
            .then(response => response.data);
    }
How i need to take fullname when i have only creator code?

我有一个列表页面,其中有新闻和建议发布,并且有评论属于新闻和建议的另外两个功能,我有一个creatorKod(评论创建者),并有代码获取创建者全名的web服务员工代码 . 我怎么能用顶部的代码呢?

1 回答

  • 0

    我实际上并没有得到你所说的但是我理解你想要将数据从axios返回到另一个函数,因为你可以使用 callback 函数来返回特定的数据

    这里的完整代码可能有所帮助

    ApiEmployees.getEmployeeByCode=function(creatorKod, callback){
      axios.post('http://localhost:8080/comment',{
        code:data.user_code
      }).then(response =>{
        callback(response.data.message);
        callback(response.data.fullname
        console.log(response.data.message);
      }).catch(err =>{
        console.log(err);
      })
    }
    

相关问题