I am trying to check if the url of an image is 404 or not. The problem is that the function is returning undefined. Why is this happening?
If I console.log the status of the res it does show 404 so the if statement is being executed.
function checkImageURL(url){
fetch(url)
.then(res => {
if(res.status == 404){
console.log(res.status)
return <Image source={require('./Images/default.png')}/>
}else{
return <Image source={{uri: `${url}`}} />
}
})
}