Closed Mansi1 closed 3 years ago
Hello. This is not a bug, it's just how this
works in JavaScript. And I meant this method to have such behaviour.
According to your code:
You trying to get a reference to getComputedLength
and put it to a constant. This is where the method gets unbound from FormData
instance. However, the To fix your problem, you need to call getComputedLength right from the stream
is property created in FormData
constructor, so it keeps a reference to FormData instance. Similar for headers
- it is getter, so you'll have its result once you access it.FormData
instance, or bind
it first:
const contentLength = bodyToSend.getComputedLength()
// or
const getComputedLength = bodyToSend.getComputedLength.bind(bodyToSend)
I think the last one would be unnecessary for your use-case.
Issue in function scope got this problem, writting a new fetch implementation.
fix use arrow function