store staggered output from chrome console into single variable and copy it

Below is the code to scrape data from a particular site using tag and id name:

document.querySelectorAll("div #menu a").forEach((item)=>(fetch(item.href).then(res => res.text()).then(data => console.log(data))));

Here menu is id name of div tag of anchor tag, item returns all the filtered anchor tags that i want to store locally.

I want to return the output in single var "data" but the output i am getting is in staggered manner like one url entirely then its showing to copy that code and then next same thing for another url and so on

54 thoughts on “store staggered output from chrome console into single variable and copy it”