1

I am attempting to use the fetch in my TestCafe function but it is returning the ClientFunction and not the Response.

Also if I try to use await with fetch is telling me it is reserved.

This is to pass multiple URLs and get the status back without having to navigate to URL and get the current window. TestCafe logger seems not to accept URLs without loading the page (i could be incorrect though)

var response = await fnct.responseHttp('https://www.teenvogue.com/story/shawn-mendes-camila-cabello-romantic-body-language-explained-by-expert');

export async function responseHttp(url) {
  let response = await ClientFunction(() => {
    let resulting = fetch(url).then(function(response) { return 
response.status; })
  });
   return resulting; //also tried returning 'response'
}

I want to pass a URL and fetch the data to assert response status. I can successfully do this in the console but I haven't successfully had it work in TestCafe. I can get URL responses to work if I get current window location but not passing in URLs.

await fetch returns 'fetch is reserved'

fetch alone is returning what seems to be just ClientFunction info.

Alex Skorkin
  • 4,264
  • 3
  • 25
  • 47
bwmathews
  • 161
  • 4
  • 1
    If the target web page accepts XHR calls, you can use the 'fetch' function to get it content. Techinaclly, it means that the response of this web page contains CORS headers (https://developer.mozilla.org/ru/docs/Web/HTTP/CORS). – mlosev Jul 12 '19 at 09:57

0 Answers0