const customImage = tmpl.customImage ? tmpl.customImage.map(c => c.url) : "https://yourl img here";
here tmpl.customImage
is getting empty array[] so i want to display a default image instead of empty. But it is not fetching to default image it is showing empty...
Please help me thanks in advance
CodePudding user response:
How about checking it length?
const customImage = tmpl.customImage.length ? tmpl.customImage.map(c => c.url) : "https://yourl img here";
CodePudding user response:
use instead of that:
const customImage = tmpl.customImage.length ? tmpl.customImage.map(c => c.url) : "https://yourl img here";
CodePudding user response:
give your image url link in that array make that variable and use res.render to render your file
CodePudding user response:
Is tmpl.customImage already an array, then why assign an array to customImage ?
You can handle the empty array here:
tmpl.customImage.push({"url":"https://yourimghere"}); // add to the end
const customImage = tmpl.customImage.shift(); // take from the top