2
0
mirror of https://github.com/tenrok/axios.git synced 2026-05-15 11:59:42 +03:00
Commit Graph

57 Commits

Author SHA1 Message Date
Zoran Kokeza 412d3bd607 Adding support for beforeRedirect config option (#3852)
* Adding support for beforeRedirect config option

* Adding tests for beforeRedirect

* Update README.md

Co-authored-by: Prabodh Meshram <prabodh.meshram7@gmail.com>

* fix types

Co-authored-by: Prabodh Meshram <prabodh.meshram7@gmail.com>
Co-authored-by: Jay <jasonsaayman@gmail.com>
2022-03-07 19:46:08 +02:00
Jay d660e29c1a Revert "Fixed isFormData predicate; (#4413)" (#4472)
This reverts commit 73e3bdb883.
2022-02-13 15:47:38 +02:00
Dmitriy Mozgovoy 73e3bdb883 Fixed isFormData predicate; (#4413)
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;
2022-02-02 13:48:44 +02:00
Felipe Carvalho 4fbf61dc75 Adding responseEncoding prop type in AxiosRequestConfig (#3918)
* Adding responseEncoding prop type in AxiosRequestConfig

* Update index.d.ts

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-12-23 19:07:46 +02:00
Stefano Magni 5431634fab Fixing Cancel' signature. (#3152) (#3153)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-12-22 20:30:50 +02:00
Brandon Faulkner 6b4fd93e68 Expand Headers types (#4144)
* Expand Headers types

* Add undefined to allowed types

* Add semicolon
2021-11-16 17:06:21 +02:00
Rodry 2c9cc76ee9 revert: change type of AxiosResponse to any (#4186)
* revert: change type of AxiosResponse to any

* types: add back default types

My bad xD

* Remove redundant default params
2021-10-22 10:14:23 +02:00
Remco Haszing 94a9344799 Test types (#4140)
* 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>
2021-10-12 09:53:10 +02:00
Dmitriy Mozgovoy fce210a67e Fixed TransitionalOptions typings (#4147)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-10-12 09:46:16 +02:00
Jay 547815d9fd Mending merge conflict 2021-10-12 09:43:02 +02:00
Evgeniy e462973a4b fix response headers types (#4136)
* fix response headers types

some keys like 'set-cookie' are arrays https://github.com/axios/axios/blob/master/lib/helpers/parseHeaders.js#L45

* split header types
2021-10-07 19:23:29 +02:00
Claas Augner 7c9a5c5c84 Fix missing semicolon in typings (#4115)
Fixes #4109.

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-10-06 21:11:00 +02:00
Remco Haszing 6c002323a6 Change never type to unknown (#4142)
* 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>
2021-10-06 20:13:06 +02:00
Claas Augner 28a06e6d95 Distinguish request and response data types (#4116)
Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-10-06 20:10:01 +02:00
Jay 76f09afc03 Release/v0.22.0 (#4107)
* 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>
2021-10-01 08:02:13 +02:00
Evan Finkelstein 2bc250786f Adding insecureHTTPParser type to AxiosRequestConfig 2021-09-15 13:47:14 -07:00
Remco Haszing 90205f8ab7 Change headers type to string record (#3021)
This correctly reflects the type in a more type safe manner.

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-09-05 14:14:12 +02:00
Remco Haszing 92b29d2775 Make the default type of response data never (#3002)
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>
2021-09-05 14:11:25 +02:00
Carlos Chida 4eeb3b17e2 Improved type-safety for AxiosRequestConfig (#2995)
* 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>
2021-09-05 14:06:05 +02:00
Tim Düsterhus 4f25380b31 Exposing the Axios constructor in index.d.ts (#2872)
This patch allows TypeScript users to extend the `Axios` class without
the type checker complaining.

see 7548f2f79d

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-09-05 12:48:46 +02:00
hippo 69949a6c16 Adding custom return type support to interceptor (#3783)
close #3448

Co-authored-by: Jay <jasonsaayman@gmail.com>
2021-05-14 16:08:36 +02:00
Dmitriy Mozgovoy 5ad6994da3 JSON improvements: throw if JSON parsing failed; number, boolean can be passed directly as payload for encoding to JSON #2613, #61, #907 (#3688)
* 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);
2021-04-19 18:55:34 +02:00
Jason Kwok f472e5da5f Adding a type guard for AxiosError (#2949)
Co-authored-by: Jason Kwok <JasonHK@users.noreply.github.com>
2020-11-03 10:01:07 +02:00
Remco Haszing 820fe6e41a Updating axios in types to be lower case (#2797)
Co-authored-by: Xianming Zhong <chinesedfan@qq.com>
2020-10-27 20:36:32 +08:00
Taemin Shin 3a8b87d48a Fixing an issue that type 'null' and 'undefined' is not assignable to validateStatus when typescript strict option is enabled (#3200) 2020-10-20 08:04:44 +02:00
Remco Haszing b7e954eba3 Fixing node types (#3237)
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>
2020-10-01 09:42:09 +02:00
Taemin Shin b03f16159e Fixing an issue that type 'null' is not assignable to validateStatus (#2773)
Co-authored-by: Xianming Zhong <chinesedfan@qq.com>
Co-authored-by: Jay <jasonsaayman@gmail.com>
2020-05-27 19:18:28 +02:00
Benny Neugebauer c120f44d3d Fixing 'progressEvent' type (#2851)
* Fix 'progressEvent' type

* Update axios.ts
2020-03-28 17:51:42 +08:00
Motonori Iwata 5189afff38 Allow PURGE method in typings (#2191)
Co-authored-by: Xianming Zhong <chinesedfan@qq.com>
2020-03-07 14:45:25 +08:00
Spencer von der Ohe 42eb9dfabc Adding option to disable automatic decompression (#2661)
* 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>
2020-03-06 22:01:58 +08:00
Gustavo López 6642ca9aa1 Add independent maxBodyLength option (#2781)
* Add independent option to set the maximum size of the request body

* Remove maxBodyLength check

* Update README

* Assert for error code and message
2020-03-06 21:55:19 +08:00
Luke Policinski bbfd5b1395 Adding options typings (#2341) 2019-11-03 21:17:27 -08:00
Marlon Barcarol b0afbedf1b Adding Typescript HTTP method definition for LINK and UNLINK. (#2444) 2019-11-03 19:29:51 -08:00
IVLIU 6284abfa06 custom timeout prompt copy (#2275)
* style: ui

* feat: custom timeout txtx

* feat: custom timeout txtx
2019-10-15 22:29:16 -03:00
Tiago Rodrigues 006b60425c Add toJSON property to AxiosError type (#2427)
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.
2019-09-26 09:11:34 -03:00
Suman Lama 047501f708 Makes Axios error generic to use AxiosResponse (#1738) 2019-05-07 15:14:57 -04:00
Ken Powers 75c8b3f146 Allow uppercase methods in typings. (#1781) 2018-09-17 18:25:07 +02:00
Alexander Trauzzi 7db0494579 Add getUri signature to TypeScript definition. (#1736)
* Add `getUri` signature to TypeScript definition.

This is in support of #1624.

* Make configuration optional.
2018-08-21 08:24:53 -06:00
Ayush Gupta b681e919c4 Adding isAxiosError flag to errors thrown by axios (#1419) 2018-08-20 11:02:23 +02:00
Khaled Garbaya 7d9a29ee4c Fixing http adapter to allow HTTPS connections via HTTP (#959) 2018-07-04 23:51:11 -07:00
Sako Hartounian 84388b0389 cleaner definitions with union types. (#1551) 2018-07-04 23:48:07 -07:00
Stephan Schneider 73cab975f0 typings: allow custom return types
response interceptor might change the type from AxiosResponse to anything they like
2018-06-18 10:48:29 +02:00
Shane Fitzpatrick dd16944ecf Adding better 'responseType' and 'method' type definitions by using a string literal union type of possible values (#1148) 2018-04-08 00:19:46 -07:00
Yutaro Miyazaki 524f5bf10a fix: Fix type error when socketPath option in AxiosRequestConfig 2018-04-06 20:44:20 -07:00
Andrew Scott fbb29e07cc Fixing missing type parameters on delete/head 2018-03-07 22:13:02 -08:00
Punit Gupta 521a429f2d fix(index.d.ts): Remove redundant types 2017-12-21 15:24:34 +05:30
Punit Gupta 423923217e Fixing interface of axios instance 2017-11-20 21:53:47 +05:30
niris f0293696e7 Fixing typing issues #1154 #1147 2017-11-12 12:30:02 +08:00
Paul Sachs 1005e3bf14 Updating typings
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 => {
...
});
```
2017-11-03 11:57:12 -04:00
Nick Uraltsev 8bea343f3d Merge pull request #1125 from keenondrums/master
Update AxiosTransformer type in index.d.ts
2017-10-24 07:51:08 -07:00