`gaxios` treats `arraybuffer` differently from `axios`
See original GitHub issueThanks for stopping by to let us know something could be better!
PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.
Please run down the following list and make sure you’ve tried the usual “quick fixes”:
- Search the issues already opened: https://github.com/googleapis/google-api-nodejs-client/issues
- Search the issues on our “catch-all” repository: https://github.com/googleapis/google-cloud-node
- Search StackOverflow: http://stackoverflow.com/questions/tagged/google-cloud-platform+node.js
If you are still having issues, please be sure to include as much information as possible:
Environment details
- OS: MacOS
- Node.js version: 10.5.0
- npm version: 6.7.0
googleapis
version: 37.0.0
Steps to reproduce
With the move to gaxios
from axios
, there’s a few things that have changed with regard to how node-fetch
handles arraybuffer
differently from axios
. (Mainly, it does nothing to it at all 🙃 .) I will say that this is not necessarily a bug, but for anyone else who depends on this to run drive.files.export
calls may be surprised the exported files stop working.
In axios
, it will convert an ArrayBuffer
to a Buffer
as part of the request, but node-fetch
leaves that up to the user.
So in pre-37.0.0 land, this would work fine (and return a Buffer
at res.data
):
const res = await drive.files.export(
{
fileId: spreadsheetId,
mimeType:
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
},
{ responseType: 'arraybuffer' }
);
But now in 37.0.0, you may have to pass that to Buffer.from
before you can potentially use it.
Like I said above - this may not actually be a “bug” in the traditional sense, but seeing as I learned the tip of how to use arraybuffer
with drive.files.export
to pull down Excel files from the issues of this library, I figured I’d flag it just in case it’s worth noting somewhere? (Just not sure… where?)
Thanks for the library!
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top GitHub Comments
@JustinBeckwith Sounds good! I agree. Probably best to let fetch continue to work like fetch, it’ll not be an issue as this change becomes the understood “default.” (I adjusted in my code and it has been fine ever since.) Hopefully folks will find this if they happen to hit it. 👍
Given the current behavior makes a lot more sense, I’m content to close this one out. Please do let me know if there’s anything else we could do here!