I'm loading an image from a S3 bucket in my Ionic view like this:
<ion-avatar>
<img class="circle" src="https://s3-sa-east-1.amazonaws.com/mybucket/cp{{client?.id}}.jpg">
</ion-avatar>
The image name I want to load is "cp1.jpg", and the client?.id value 1 is taken from the component script:
ionViewDidLoad() {
let email = this.storage.getLocalUser().email;
this.clientService.findByEmail(email)
.subscribe(resp => {
this.client = resp;
},
error => {
console.log(error);
});
}
I'm also using the "?" operator in client?.id because if I don't, I get an "id undefined" error and the page doesn't even load.
However, I'm getting a canceled request on my Network inspector, which is trying to retrieve the image before the "1" value is concatenated in the image name:
Right after that error, the "1" value is provided to the view and the image is loaded. But I'd like to not get that undesired retrieving try.
How can I properly load and bind the client id to get the image name right, and also to avoid getting that canceled request error?