I have two fetch scripts that work great at either or though I can't figure out how to combine them.
This first one allows me to know what the response.status is however even though it somehow knows the server's HTTP response while not having the response body (yeah, asynchronous):
fetch(url).then(function(r) { if (r.status != 200) {alert('Error: unable to load preview, HTTP response '+r.status+'.');} else { console.log(r.text());//Promise { <state>: "pending" }, no good. } }).catch(function(err) {alert('Error: '+err);}); This second script allows me to access the response.text() though I have no access to the response.status:
fetch(url).then(r => r.text()).then(function(r) { console.log(r);//response text. }); How do I combine the scripts properly so I have access to both the response.status and response.text() after the request has been received?