I am facing a challenge while trying to fetch an asset, specifically an image, from Contentful and display it in my Angular application. Despite seeing the images in the Network log, I keep encountering an issue where the console.log outputs undefined
. Any insights on what might be causing this?
Below is the function implemented in the component:
this.contentfulService.getContactImage()
.then(asset => this.pageImage)
.then(asset => console.log("Received Gallery Image", this.pageImage));
And here is the service code snippet:
//get Page Image
getContactImage() {
return this.cdaClient.getAsset('<asset ID>')
.then(asset => asset.fields.file.url);
}