When I write a sample of data from an array which, for example, is empty, then an error occurs. TypeError: Cannot read property text.
${data[0].text} Is it possible to somehow make it so that an empty string is returned, otherwise it is not very convenient to write if else constructs if there is a lot of nested data.
I use the vm module - the runInContext method.
const p = (el, key, def = '') => (el && el[key] || def);. And in the code to write:${p(data[0], 'text')}. - exvayn