[Vuejs]-How to return axios get value instead of [object Promise]?

3👍

You don’t need to use .then(). Just async and await.

This is how you should use them:

async encFolderID(_id){
        if(_id > 0){
            const resp = await axios.get(base_url+'Main/Process/FilesStorage/encFolderID/'+ _id);
            return resp.data.enc_id
        } else ...
    },

0👍

Why you are using .then while you marked axios with await keyword?
try this one. when using await you don’t have to use .then

async encFolderID(_id){
        if(_id > 0){
            const res = await axios.get(base_url+'Main/Process/FilesStorage/encFolderID/'+ _id)
            return res.data.enc_id
        }
    },
👤nima

Leave a comment