Dynamic meta tags in vue 3

I’m about to make dynamic meta tags in vue-cli using vue-meta.
I made static meta tags for different pages, but I want to set meta tags using API requests, like this:

export default {
    data() {
        return {
            employee: {
                "name": ""
    mounted() {
            this.employee.name = response.data.employee.name
    setup () {
            title: this.employee.name,
            htmlAttrs: { lang: 'en', amp: true }

but this code will ran an error cause it can’t find this!
Can someone help?

You’re mixing Composition API and the “old” Options API here. You should get rid of “data” and “mounted” and use just the setup method. There you can define your “employee” and also fetch your data within “onMounted”.

Keep in mind that when setup is executed, the component instance has not yet been created. At this point, you will not have access to data. You will either need to account for this or stick with just the options api and follow these instructions to use it with vue-meta.