I have blog in vue.js I want to preview each post separately. I do this>
export default{
name: 'post',
props:['id'],
data(){
return {
singlePost: { }
}
},
created() {
BlogPostsApi.getPost(this.id)
.then(response => {
console.log(response)
this.singlePost = response.data
})
}
in blogPosts.js i have this code>
import axios from'axios';
export default{
getPost (id) {
return axios.get('http://localhost:8000/api/posts/ddc/' + id)
.then(response => {
debugger
return response.data
})
}
}
When i'm debugging i get this error Message Cannot read property 'singlePost' of undefined
singlePost. Which line of your code does the error point to? - Phil