@Alex-Archer-I
Posted
Hi!
Congrats with your first project with external API =)
You are using fetch right, but I suggest you to threw an error if response isn't ok (that way it'll be passed directly in the catch part).
And you can switch between two images on different versions more easier with picture
tag:
<picture>
<source srcset="mobile.jpg" media="(max-width: 900px)">
<img src="desktop.jpg" alt="">
</picture>
It contains one or more source
tags with different media conditions which it use to render corresponding image, and img
tag for default image.
Oh, you have a little mistype on the 27th line =)
}).catch(error=>[ --- should be { here =)
@Navroz-Singh
Posted
@Alex-Archer-I Thanks you so much for pointing out the mistakes and providing me with the optimizations, I will make sure to consider all these points while working on my next project. Also, I have corrected the parentheses typo. Thank you again for the great advice.
@Alex-Archer-I
Posted
@Navroz-Singh
You're welcome, glad I could help =)