Added support for automatic object serialization to FormData if `Content-Type` is `multipart/form-data`;
Added support for FormData to be overloaded using `config.env.FormData` option;
Added support for FormData in node.js environment through `form-data` package;
* Distinguish request and response data types
* Fix Axios headers type
`axios.headers` is not of the same type as `request.headers`, so a new type
`AxiosDefaults` was introduced
* Replace grunt-ts with dtslint
This asserts that the type definitions are valid in the specified TypeScript
version and above. This is the same tool that is used by DefinitelyTyped.
* Remove grunt-ts
* Restore typescript dependency
* Fix missing semicolons
Co-authored-by: Claas Augner <github@caugner.de>
Co-authored-by: Jay <jasonsaayman@gmail.com>
* Distinguish request and response data types
* Change never type to unknown
Using `never` was a workaround I introduced in 3002, because `unknown` wasn’t
supperted by all relevant versions of TypeScript at the time. It is now, and
it is much more correct.
Co-authored-by: Claas Augner <github@caugner.de>
Co-authored-by: Jay <jasonsaayman@gmail.com>
* fix/Avoid package.json import; (#4041)
* Added auto-generated config module `env/data.js` for importing package environment vars without importing the whole `package.json`;
Refactored `http.js` to use `env/data.js` instead of package.json;
* Added `env/data.js`;
Added `env/README.md`;
* Feat/export package version constant (#4065)
* Added auto-generated config module `env/data.js` for importing package environment vars without importing the whole `package.json`;
Refactored `http.js` to use `env/data.js` instead of package.json;
* Added `env/data.js`;
Added `env/README.md`;
* Export package version constant;
* Fixed cancelToken leakage; Added AbortController support; (#3305)
* Fixed cancelToken leakage;
Added AbortController support;
* Fixed typings;
* Documented `signal` option;
* Added processing of early cancellation using AbortController without sending a request;
Co-authored-by: Jay <jasonsaayman@gmail.com>
* Updating CI to run on release branches
* Fixed default transitional config for custom Axios instance; (#4052)
Refactored `/core/mergeConfig`;
Co-authored-by: Jay <jasonsaayman@gmail.com>
* Prepping v0.22.0 for release
* Updated date
Co-authored-by: Dmitriy Mozgovoy <robotshara@gmail.com>
This requires TypeScript users to explicitly define the type of the data they
are consuming.
Before this, data was `any` by default. This means TypeScript consumers didn’t
get type safety if they forgot to specify the type.
Technically this is a breaking change for TypeScript users, as this will report
errors if they forgot to specifiy the response type. The simplest workaround
would be to explicitly set the response type to `any`, so it’s not breaking
much.
The `unknown` type is probably a slightly better fit, but this requires
TypeScript ^3.
`data` is still `any` in the very specific use case mentioned in
https://github.com/microsoft/TypeScript/issues/38969
Co-authored-by: Jay <jasonsaayman@gmail.com>
* Improved type-safety for AxiosRequestConfig
- AxiosRequestConfig is now a generic type whose template corresponds to data
Signed-off-by: Carlos Chida <carlos.chida@starchitecture.eu>
* Fixed tests
- TS tests now match the behaviour described in the PR
Signed-off-by: Carlos Chida <carlos.chida@starchitecture.eu>
Co-authored-by: Jay <jasonsaayman@gmail.com>
This patch allows TypeScript users to extend the `Axios` class without
the type checker complaining.
see 7548f2f79d
Co-authored-by: Jay <jasonsaayman@gmail.com>
* Draft
* Added support for primitive types to be converted to JSON if the request Content-Type is 'application/json';
Added throwing SyntaxError if JSON parsing failed and responseType is json;
Added transitional option object;
Added options validator to assert transitional options;
Added transitional option `silentJSONParsing= true` for backward compatibility;
Updated README.md;
Updated typings;
* Fixed isOlderVersion helper;
Fixed typo;
Added validator.spec.js;
* Added forcedJSONParsing transitional option #2791
* `transformData` is now called in the default configuration context if the function context is not specified (for tests compatibility);
* Added `transitional.clarifyTimeoutError` to throw ETIMEDOUT error instead of generic ECONNABORTED on request timeouts;
Added support of onloadend handler if available instead of onreadystatechange;
Added xhr timeout test;
Fixed potential bug of xhr adapter with proper handling timeouts&errors (FakeXMLHTTPRequest failed to handle timeouts);
The `ProgressEvent` type comes from the `DOM` lib. This is typically unwanted
when using axios in a NodeJS environment.
Co-authored-by: Jay <jasonsaayman@gmail.com>
* Adding ability to disable auto decompression
* Updating decompress documentation in README
* Fixing test\unit\adapters\http.js lint errors
* Adding test for disabling auto decompression
* Removing changes that fixed lint errors in tests
* Removing formating change to unit test
Co-authored-by: Xianming Zhong <chinesedfan@qq.com>
I noticed the error object has a `toJSON` method but when I tried to use it in my typescript code it complained it didn't exist, even though I was using the `AxiosError` type.
The first argument in `axios.interceptors.response.use` is optional, in the case that you just want to intercept an error.
Ex:
```ts
axios.interceptors.response.use(undefined, error => {
...
});
```