arrays - Instead of null, send a message for no value in Javascript
Solution:
Try out the below code this should fix your bug if not then let me know. I will try another method of rendering an empty statement.
const emptyStatement = () => {
const empty_Statement = "You have no wishlist item.";
const resetWishlist = empty_Statement;
return setWishlist([empty_Statement]);
document.getElementById("oasis-wishlist").innerHTML = emptyStatement();
};
Answer
Solution:
Ok. so here you can add a condition while fetching Wishlist products. ifproductarr.length==0
then set the inner HTML of Wishlist to<h1> Wishlist empty </h1>
else if there is data then print the data as per your choice. i can't actually provide the code because it will alter whole of your code. apply the above logic accordingly and that will fix your code.
fetch(url).then((res)=>
{
if(res.data.length)
setwihslist([res.data])
else
wishlist.innerHTML="emptywishlist";
}
Source
Didn't find the answer?
Our community is visited by hundreds of Shopify development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.