-
-
Notifications
You must be signed in to change notification settings - Fork 418
Description
A generated client with Axios won't work as expected when executed from Node as you'll get the following error: ReferenceError: File is not defined.
The reason is that the following checks were added in #350 in response to #293:
| const isFileType = formItem instanceof Blob || formItem instanceof File; |
File isn't supported on Node, and based on the description of this project, it seems like generated clients should be working from both Node and browsers, so we shouldn't reference File in here.
Expected Behavior
Uploading a file / using multipart/form-data / using FormData should work as expected from browsers and Node environments.
Actual Behavior
It works as expected within browsers but crashes with the following error on Node: ReferenceError: File is not defined.
Potential Solution
File inherits from Blob, meaning that an instance of File will always be an instance of Blob as Blob constructor's prototype property appears in the prototype chain of File's instance:
new File(['foo'], 'foo.txt') instanceof Blob // trueIt means that we should be able to strip the usage of File completely and only rely on Blob, which is supported by all environments.