[Vuejs]-Vue Method returns [object Promise]

-1👍

That’s because you need to have the .then on the function not inside the function. What is happening is the function doesn’t complete execution and moves on since you did not use a .then after it.
try this:

data: () => ({ something: null})
...
async searchWord(rawString) {
            const splitRawString = rawString.match(/^(\w\w\w)\d/);
            if (splitRawString) {
                // If regex found a match
                this.something =  await axios
                    .get(`https://www.url.com/path/${splitRawString[1]}`)

            }
        }
    }

Stick something in your template instead of the function itself.

Leave a comment