Welcome back.
Sometimes the image of the news headline might not be available, and this is a problem with the API
service, the API service might not provide some of the news and lines images for some reason, and
to fix this, we can display a default image and gives the image doesn't exist.
So I I have a you are able that I'm going to be using and you can use it as well.
In case the image doesn't exist, we can display that image.
So here we need to check whether the image is empty or not.
So here I'm going to say Beach B. And then if I'm going to add if statement, I'm going to say if.
And then is not empty.
Or, let's say, empty, if empty.
If empty.
Object.
You are able to image if the image is empty.
What I'm going to do is that I'm going to open a Carnley brackets and then I'm going to say anything
else.
And then I'm going to open Caleb Bracket and then I'm going to close it at the end and pay attention
to the syntax because it's a very tricky syntax.
So here inside these curly brackets, what do we want to do is that when you want to say Echo, and
then I'm going to base that, you want the default you want out.
So this is the default, the ordeal I've been, I'm going to add semicolon.
And if you want to use this, you want you can now pause the video and type this out again.
If you want to use my mind you want, you can pause the video right now and type that type that out.
Again, this is the audio, and again, you need to double check the syntax.
Alimi explain the syntax one more time.
Here I'm checking if the object you are able to image is empty.
If it's empty, then I'm going to be displaying this you.
What else else?
If it's not empty, it means that the audio exists, then I'm going to display that you are able that
has been provided by the service.
Finally, I'm going to click on file Invincible.
Let me turn over to the browser and refresh.
And as you can see, and as you can see, in case we have the image, the image will be displayed,
the real the image that's related to the news headline will be displayed displayed.
Otherwise the default image will be displayed on the look of our website.
Will will not be ruined because of this.
So this is a great fix to this problem.
If the image doesn't exist, this this is going to always be the default image.
Otherwise, it's going to display the correct image.