0👍
Thats not the way to use asyncData
You want to grab the SEO boost for that specific page but you wont get it if you call an method that doesnt return nothing.
Also you use async
but i do not see any await
. Anyway try this out
async asyncData ({ error }) {
try {
const trendingMovies = await this.treding('movies');
const trendingSeries = await this.treding('series');
return { trendingMovies, trendingSeries};
} catch {
error({ statusCode: 504, message: 'Data not available' });
}
},
methods: {
async treding(media) {
let { data } = await axios.get('/api/v1/get/type/' + media);
return data.list;
}
}
Source:stackexchange.com