As discussed in the comments,
forEach
does not return anything. A combination of
filter
and
map
is probably what's required:
const site = document.querySelector('.plain-text-display').textContent.split('\n').filter(line => line.includes('test')).map(line => line.split(', ')[0]);
Array.prototype.filter() - JavaScript | MDN[
^]
Array.prototype.map() - JavaScript | MDN[
^]
Also, sending a content type of
application/x-www-form-urlencoded
with a JSON body probably won't work, and will simply confuse the server.