my intention is to get some data from api,
then put in the head(){} to set description and title,
but it keep telling me val.replace is not a function,
here is my code
async mounted() {
...await call api...
if (resDataGetNewsInfo.return_code === 0) {
vm.newsInfoObj = resDataGetNewsInfo.return_msg;
} else {
...
}
...
asyncData() {
return {
newsInfoObj: '',
};
},
...
head() {
return {
description: this.newsInfoObj.news_short_desc,
meta: [
{
hid: 'og:title',
property: 'og:title',
content: this.newsInfoObj.news_title,
},
Uncaught TypeError: val.replace is not a function
thanks for answering
Thats not the way to use
asyncData
.Your API call should be called inside the
asyncData
and then return your data