axios-fetch
axios-fetch copied to clipboard
Support 204 no-content for node 18
In Node.js 18, an experimental global fetch API is available by default (https://nodejs.dev/en/blog/announcements/v18-release-announce#fetch-experimental). axios-fetch
currently assumes node-fetch
as the underlying fetch mechanism.
This has compatibility issues in Node v18's fetch implementation for handling of 204 no-content results.
Nodes fetch (backed by undici
) expects a 204 response to have a nullable body, however axios-fetch
returns an empty buffer, resulting in the following error
TypeError {
message: 'Response constructor: Invalid response status code 204',
}
The expectation is that axios-fetch
also returns a nullable body for 204 no-content responses.
The current workaround to this is to avoid utilising nodes fetch
impl via --no-experimental-fetch
or override our global references with node-fetch