Skip to content

fix: map axios responseType to correct Response method name#5

Open
Minnzen wants to merge 1 commit into
divyam234:mainfrom
Minnzen:fix/arraybuffer-response-type
Open

fix: map axios responseType to correct Response method name#5
Minnzen wants to merge 1 commit into
divyam234:mainfrom
Minnzen:fix/arraybuffer-response-type

Conversation

@Minnzen

@Minnzen Minnzen commented Mar 9, 2026

Copy link
Copy Markdown

Problem

Using responseType: "arraybuffer" throws:

AxiosError: res[(options.responseType || "text")] is not a function

The current code calls res[options.responseType || "text"]() directly on the Fetch API Response object. Axios uses "arraybuffer" (lowercase) but the Fetch API method is arrayBuffer() (camelCase), so res["arraybuffer"] is undefined.

Fix

Map "arraybuffer" to "arrayBuffer" before calling the method on Response.

Test

Added a test case that sends a binary response and requests it with responseType: "arraybuffer". Without the fix it throws the error above; with the fix it returns an ArrayBuffer as expected.

`responseType: "arraybuffer"` causes `res["arraybuffer"]()` which throws
because the Fetch API Response method is `arrayBuffer()` (camelCase).

Added a test case that reproduces the crash and verifies the fix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant