I have been able to make requests to a contentful API where I have blogs in them. It suddenly stopped working today but I cannot figure out what I changed, or what the issue is. the message I get Cannot read properties of undefined (reading 'file') doesn't make sense because there is an image there.
Beow is the method that gets blogs
async getAllBlogs(limit = this.limit, skip = 0) {
var response = await this.$contentful.client.getEntries({
content_type: 'blog',
order: 'fields.id',
limit,
skip
})
let blogs = response.items;
blogs = blogs.map((item) => {
const { id, createdAt } = item.sys;
const { slug, title, description } = item.fields;
const thumbnail = item.fields.thumbnail.fields.file.url
return{
id, slug, title, thumbnail, description, createdAt
}
})
console.log(blogs);
return this.blogs = blogs;
},
But with this i get in my console
index.vue?6ced:58 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'file')
at eval (index.vue?6ced:58:1)
at Array.map (<anonymous>)
at _callee$ (index.vue?6ced:55:1)
at tryCatch (runtime.js?96cf:63:1)
at Generator.invoke [as _invoke] (runtime.js?96cf:294:1)
at Generator.eval [as next] (runtime.js?96cf:119:1)
at asyncGeneratorStep (asyncToGenerator.js?1da1:3:1)
at _next (asyncToGenerator.js?1da1:25:1)
Please, what could be the problem?