I have some code that wants to issue a request and check whether the request is successful, but it does not care about the response body:
async function doTheThing() {
const response = await fetch(someUrl, { method: 'POST' });
if (!response.ok) {
throw new Error(`Request failed with status ${response.status}`);
}
}
As I understand it, the response body is not downloaded yet at this point. If we leave it hanging and don't follow up with something like:
const body = await response.json();
...will the request/response remain open and waiting until perhaps GC occurs? If so, is there a way to cleanly ignore the rest of the response stream without causing issues?