I want to access data object in mounted hook, but when I try to access the data it will throw undefine in the console.
This is my source code
export default {
data() {
return {
channel: {},
subscription: {},
}
},
methods: {
read() {
axios.get('/api/get/details').then(({ data }) => {
this.channel= data;
})
.catch((err) => console.error(err));
},
},
mounted() {
this.read();
console.log(this.channel.data.userid)
fetch("https://url/v1/launch/1/details")
.then(response => response.json())
.then(json => {
this.subscription = json
});
}
}
but when I console this.channel.data.userid
I gat 'undefine'