Skip to content

Commit

Permalink
Refactored AxiosError to a constructor;
Browse files Browse the repository at this point in the history
Refactored `Cancel` to a constructor, a subclass of the `AxiosError`;
Expose CanceledError class;
Refactored axios error codes;
Added `toFlatObject` util;
  • Loading branch information
DigitalBrainJS committed Oct 14, 2021
1 parent 90205f8 commit e7f33e6
Show file tree
Hide file tree
Showing 46 changed files with 974 additions and 532 deletions.
245 changes: 124 additions & 121 deletions .eslintrc.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Expand Up @@ -2,9 +2,9 @@ name: ci

on:
push:
branches: [master]
branches: [master, 'release/*']
pull_request:
branches: [master]
branches: [master, 'release/*']

jobs:
build:
Expand All @@ -19,6 +19,6 @@ jobs:
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm test
61 changes: 61 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,66 @@
# Changelog

### 0.23.0 (October 12, 2021)

Breaking changes:
- Distinguish request and response data types ([#4116](https://github.com/axios/axios/pull/4116))
- Change never type to unknown ([#4142](https://github.com/axios/axios/pull/4142))
- Fixed TransitionalOptions typings ([#4147](https://github.com/axios/axios/pull/4147))

Fixes and Functionality:
- Adding globalObject: 'this' to webpack config ([#3176](https://github.com/axios/axios/pull/3176))
- Adding insecureHTTPParser type to AxiosRequestConfig ([#4066](https://github.com/axios/axios/pull/4066))
- Fix missing semicolon in typings ([#4115](https://github.com/axios/axios/pull/4115))
- Fix response headers types ([#4136](https://github.com/axios/axios/pull/4136))

Internal and Tests:
- Improve timeout error when timeout is browser default ([#3209](https://github.com/axios/axios/pull/3209))
- Fix node version on CI ([#4069](https://github.com/axios/axios/pull/4069))
- Added testing to TypeScript portion of project ([#4140](https://github.com/axios/axios/pull/4140))

Documentation:
- Rename Angular to AngularJS ([#4114](https://github.com/axios/axios/pull/4114))

Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub:

- [Jay](mailto:jasonsaayman@gmail.com)
- [Evan-Finkelstein](https://github.com/Evan-Finkelstein)
- [Paweł Szymański](https://github.com/Jezorko)
- [Dobes Vandermeer](https://github.com/dobesv)
- [Claas Augner](https://github.com/caugner)
- [Remco Haszing](https://github.com/remcohaszing)
- [Evgeniy](https://github.com/egmen)
- [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS)

### 0.22.0 (October 01, 2021)

Fixes and Functionality:
- Caseless header comparing in HTTP adapter ([#2880](https://github.com/axios/axios/pull/2880))
- Avoid package.json import fixing issues and warnings related to this ([#4041](https://github.com/axios/axios/pull/4041)), ([#4065](https://github.com/axios/axios/pull/4065))
- Fixed cancelToken leakage and added AbortController support ([#3305](https://github.com/axios/axios/pull/3305))
- Updating CI to run on release branches
- Bump follow redirects version
- Fixed default transitional config for custom Axios instance; ([#4052](https://github.com/axios/axios/pull/4052))

Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub:

- [Jay](mailto:jasonsaayman@gmail.com)
- [Matt R. Wilson](https://github.com/mastermatt)
- [Xianming Zhong](https://github.com/chinesedfan)
- [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS)

### 0.21.4 (September 6, 2021)

Fixes and Functionality:
- Fixing JSON transform when data is stringified. Providing backward compatability and complying to the JSON RFC standard ([#4020](https://github.com/axios/axios/pull/4020))

Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub:

- [Jay](mailto:jasonsaayman@gmail.com)
- [Guillaume Fortaine](https://github.com/gfortaine)
- [Yusuke Kawasaki](https://github.com/kawanet)
- [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS)

### 0.21.3 (September 4, 2021)

Fixes and Functionality:
Expand Down
40 changes: 21 additions & 19 deletions Gruntfile.js
@@ -1,3 +1,4 @@
// eslint-disable-next-line strict
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);

Expand All @@ -11,19 +12,6 @@ module.exports = function(grunt) {
dist: 'dist/**'
},

ts: {
test: {
options: {
lib: [
'es5',
'es2015.promise',
'dom'
]
},
src: ['typings/index.d.ts', 'test/typescript/*.ts']
}
},

package2bower: {
all: {
fields: [
Expand All @@ -37,6 +25,10 @@ module.exports = function(grunt) {
}
},

package2env: {
all: {}
},

usebanner: {
all: {
options: {
Expand Down Expand Up @@ -70,8 +62,8 @@ module.exports = function(grunt) {
src: ['test/unit/**/*.js']
},
options: {
timeout: 30000,
},
timeout: 30000
}
},

watch: {
Expand All @@ -88,20 +80,30 @@ module.exports = function(grunt) {
webpack: require('./webpack.config.js')
});

grunt.registerMultiTask('package2bower', 'Sync package.json to bower.json', function () {
grunt.registerMultiTask('package2bower', 'Sync package.json to bower.json', function() {
var npm = grunt.file.readJSON('package.json');
var bower = grunt.file.readJSON('bower.json');
var fields = this.data.fields || [];

for (var i=0, l=fields.length; i<l; i++) {
for (var i = 0, l = fields.length; i < l; i++) {
var field = fields[i];
bower[field] = npm[field];
}

grunt.file.write('bower.json', JSON.stringify(bower, null, 2));
});

grunt.registerTask('test', 'Run the jasmine and mocha tests', ['eslint', 'mochaTest', 'karma:single', 'ts']);
grunt.registerMultiTask('package2env', 'Sync package.json to env.json', function() {
var npm = grunt.file.readJSON('package.json');
grunt.file.write('./lib/env/data.js', [
'module.exports = ',
JSON.stringify({
version: npm.version
}, null, 2),
';'].join(''));
});

grunt.registerTask('test', 'Run the jasmine and mocha tests', ['eslint', 'mochaTest', 'karma:single']);
grunt.registerTask('build', 'Run webpack and bundle the source', ['clean', 'webpack']);
grunt.registerTask('version', 'Sync version info for a release', ['usebanner', 'package2bower']);
grunt.registerTask('version', 'Sync version info for a release', ['usebanner', 'package2bower', 'package2env']);
};
22 changes: 19 additions & 3 deletions README.md
Expand Up @@ -452,6 +452,9 @@ These are the available config options for making requests. Only the `url` is re
cancelToken: new CancelToken(function (cancel) {
}),

// an alternative way to cancel Axios requests using AbortController
signal: new AbortController().signal,

// `decompress` indicates whether or not the response body should be decompressed
// automatically. If set to `true` will also remove the 'content-encoding' header
// from the responses objects of all decompressed responses
Expand All @@ -474,7 +477,7 @@ These are the available config options for making requests. Only the `url` is re
silentJSONParsing: true, // default value for the current Axios version

// try to parse the response string as JSON even if `responseType` is not 'json'
forcedJSONParsing: true;
forcedJSONParsing: true,

// throw ETIMEDOUT error instead of generic ECONNABORTED on request timeouts
clarifyTimeoutError: false,
Expand Down Expand Up @@ -734,7 +737,20 @@ axios.get('/user/12345', {
cancel();
```

> Note: you can cancel several requests with the same cancel token.
Axios supports AbortController to abort requests in [`fetch API`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API#aborting_a_fetch) way:
```js
const controller = new AbortController();

axios.get('/foo/bar', {
signal: controller.signal
}).then(function(response) {
//...
});
// cancel the request
controller.abort()
```

> Note: you can cancel several requests with the same cancel token/abort controller.
> If a cancellation token is already cancelled at the moment of starting an Axios request, then the request is cancelled immediately, without any attempts to make real request.
## Using application/x-www-form-urlencoded format
Expand Down Expand Up @@ -869,7 +885,7 @@ You can use Gitpod an online IDE(which is free for Open Source) for contributing

## Credits

axios is heavily inspired by the [$http service](https://docs.angularjs.org/api/ng/service/$http) provided in [Angular](https://angularjs.org/). Ultimately axios is an effort to provide a standalone `$http`-like service for use outside of Angular.
axios is heavily inspired by the [$http service](https://docs.angularjs.org/api/ng/service/$http) provided in [AngularJS](https://angularjs.org/). Ultimately axios is an effort to provide a standalone `$http`-like service for use outside of AngularJS.

## License

Expand Down
2 changes: 1 addition & 1 deletion bower.json
@@ -1,7 +1,7 @@
{
"name": "axios",
"main": "./dist/axios.js",
"version": "0.21.3",
"version": "0.23.0",
"homepage": "https://axios-http.com",
"authors": [
"Matt Zabriskie"
Expand Down

0 comments on commit e7f33e6

Please sign in to comment.