Andrew Fletcher published: 18 June 2022 1 minute read
ERROR Error: Uncaught (in promise): TypeError: undefined is not an object (evaluating 'ce.imageURL')
Tools
Platform / package | Version |
---|---|
Xcode | 13.2.1 |
Typescript / Angular | 6 |
Cordova | |
Capacitor |
The code where the error was being generated
if (!this.imageCollection) {
return baseUrl + req;
}
let image = this.imageCollection.find(obj => obj.fishID === fishId);
if (image.imageURL) {
return image.imageURL;
} else {
return baseUrl + req;
}
If you initialize your image attribute as an object instance with no fields. Then, on component creation: image is never undefined (so the image?.xxx in the template is useless) but image has no imageURL field. Hence, the reason that you get an error. To fix it declare your attribute as
// ....
if (image?.imageURL) {
return image.imageURL;
} else {
return baseUrl + req;
}
Related articles
Andrew Fletcher
•
17 Dec 2023
Ignoring ffi-1.16.3 because its extensions are not built. Try: gem pristine ffi --version 1.16.3
The error you're encountering indicates an issue with the ffi gem during the CocoaPods update. The error message suggests trying to run the gem pristine command to fix it.Using terminal - run the following command:gem pristine ffi --version 1.16.3This command will attempt to restore the ffi gem to...
Andrew Fletcher
•
16 Apr 2023
Xcode: Non-constant range: argument must be an integer literal error
Creating a foreach loop such as
var maxDigits: Int = 5
private var pinDots: some View {
HStack {
ForEach(0..<maxDigits) { index in
ZStack {
Image(systemName: self.getImageName(at: index))
.font(.system(size: 50.0, weight: .thin,...
Andrew Fletcher
•
12 Aug 2022
Using SwiftUI URLComponent to change a URL's scheme
The challenge I was facing, I had written a script to scan barcodes and use Google book API to view the contents. However, a snippet of the JSON response
{
"contentVersion": "0.2.0.0.preview.0",
"panelizationSummary": {
"containsEpubBubbles": false,
...