Skip to content

Error over incorrect Axios request configuration #936

@MrSlide

Description

@MrSlide

I'm using the Google APIs client 24.0.0 and the OAuth2Client from Google Auth library 1.0.0 to read a spreadsheet from Google Sheets, and it outputs a message to the console every time I make a request:

'json' is not a valid configuration option. Please use 'data' instead. This library is using Axios for requests. Please see https://github.com/axios/axios to learn more about the valid request options.

Basically when the Google APIs library makes a request to the OAuth2Client it includes json: true in the options, which is not a valid Axios option and fails the validation of the options passed to the DefaultTransporter.

I managed to trace the source of the issue back to the file src/lib/apirequest.ts and the following bit of code (taken from the non-typescript version):

options.json = resource ||
            ((options.method === 'GET' || options.method === 'DELETE') ? true : {});

The option to set the content type to JSON in Axios is responseType and it already has the default value of json, so this is not necessary.

A couple of lines below I also found this:

options.qs = params;

This options is not a valid Axios option either and the correct option is params, which is being deleted from the options object.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions