2

I have a long-running fetch process that posts a large file upload and waits for it to return a different large file :

let formData = new FormData();
formData.append('file', new Blob([file.blob], {type: file.type}), file.name);
fetch(someurl, {
  method: 'POST',
  body: formData
  cache: 'no-store'
}).then(response => {
  if (!respone.ok) throw(respone.statusText);
  return response;
}).then(response => response.blob())
.then(blob => {
... do something

Can I know what part of the process the fetch is up to - Posting the Request or Recieving the Response?

https://fetch.spec.whatwg.org/#fetch-elsewhere-fetch says fetch (js) could implement a processRequestEndOfBody and processResponseEndOfBody but the js implementation (https://fetch.spec.whatwg.org/#dom-global-fetch) doesn't seem to have them. However the chrome network inspector seems to have some clue as to the state of the request/response and I'm wondering if there's a way to glean that information at runtime? Any thoughts/discussion/alternates appreciated.

Phil
  • 157,677
  • 23
  • 242
  • 245
frumbert
  • 2,323
  • 5
  • 30
  • 61
  • Great question. If the duplicate doesn't quite answer it though, please [edit] your post to explain how and I'll re-open – Phil May 23 '22 at 00:24

0 Answers0