-1
I have an object postCardImage it is filled by a return that I have in my API, the problem is that I need to test the whole object that returned to then assign it.
I take the test like this:
postCardImage:
post._embedded["wp:featuredmedia"] |
post._embedded["wp:featuredmedia"][0] |
post._embedded["wp:featuredmedia"][0].media_details |
post._embedded["wp:featuredmedia"][0].media_details.sizes |
post._embedded["wp:featuredmedia"][0].media_details.sizes.full |
post._embedded["wp:featuredmedia"][0].media_details.sizes.full.source_url ? post._embedded["wp:featuredmedia"][0].media_details.sizes.full.source_url : ""
however I found it very big and ugly, I wondered if it would not have a more elegant way of testing that?
for example:
if(post._embedded["wp:featuredmedia"][0].media_details.sizes.full.source_url){
console.log("objeto ok");
}
This is a very common problem in my daily life, but I have not yet found a solution. What needs to be done to improve this question?
Because the negatives?
– Julio Henrique