axios icon indicating copy to clipboard operation
axios copied to clipboard

Axios should warn about options like `baseURL` being misspelled `baseUrl`

Open cincodenada opened this issue 1 year ago • 1 comments

Is your feature request related to a problem? Please describe.

I wasted half an hour today trying to figure out why my base URL wasn't being respected, before I realized that I had spelled it baseUrl instead of baseURL. Axios silently ignored my parameter - given that Axios is liberal about accepting unknown options, I'm sure I'm not the first to trip over this and waste time on a silly ambiguity in the application of camelCase.

Any solutions here should also be applied to options such as withXSRFToken, ideally in an automated way so that any new options with ambiguous camelCase representations would be automatically included.

Describe the solution you'd like

I would love if Axios simply accepted baseUrl as an optional spelling of baseURL, since Axios is already being liberal in what it accepts, and the intent is clear.

Describe alternatives you've considered

At the very least, I think it should log a warning - something like "baseUrl is likely a misspelling of baseURL" - to help point folks in the right direction.

cincodenada avatar Jul 10 '24 01:07 cincodenada

That's why projects should use TypeScript to prevent this.

suhaotian avatar Jul 20 '24 12:07 suhaotian

closing as this was merged

jasonsaayman avatar Sep 03 '25 19:09 jasonsaayman