<template>
<div>
<h1>{{ searchWord(rawString) }}</h1>
</div>
</template>
<script>
import axios from 'axios';
export default {
methods: {
searchWord(rawString) {
const splitRawString = rawString.match(/^(\w\w\w)\d/);
if (splitRawString) {
// If regex found a match
return axios
.get(`https://www.url.com/path/${splitRawString[1]}`)
.then(response => {
return response.data;
})
.catch(error => error);
}
}
}
};
</script>
In the example above, I'm trying to output the result of the axios promise.
Unfortunately, the content of the <h1>
tag is: [object Promise]
If I use console.log(response.data)
; instead of return response.data
, it works.