if im enter the webpage 127.0.0.1/?id=1 and type in the browser console
var str = document.getElementsByClassName("xyz");
document.write(str.length);i'm receiving the number i needed.
but if i use the same code with fetch in the console. i always get the number 0. how do i fix it?
fetch("http://127.0.0.1/?id=1", {
      "credentials": "include",
     "headers": {
           "User-Agent": "Mozilla/5.0 (Windows NT 10.0; rv:68.0) Gecko/20100101 Firefox/68.0",
           "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
           "Accept-Language": "en-US,en;q=0.5",
           "Upgrade-Insecure-Requests": "1",
           "Cache-Control": "max-age=0"
      },
      "method": "GET",
      "mode": "cors",
 })
.then(response => response.text())
    .then(str => {
var str = document.getElementsByClassName("xyz");
document.write(str.length);
      
})I want to get same number as I recevied in the first try. how to make getElementsByClassName and fetch work together?
 
    
return 5. but with fetch i get 0
– johns abraham Jan 26 '20 at 02:46