diff --git a/CHANGELOG.md b/CHANGELOG.md index 3632e0c8d4..c963238c7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -345,4 +345,4 @@ below) or via reviews and triaging on GitHub: ### 0.1.0 (Aug 29, 2014) -- Initial release +- Initial release \ No newline at end of file diff --git a/COLLABORATOR_GUIDE.md b/COLLABORATOR_GUIDE.md deleted file mode 100644 index 2bc7cb6fdc..0000000000 --- a/COLLABORATOR_GUIDE.md +++ /dev/null @@ -1,23 +0,0 @@ -# Collaborator Guide - -As a collaborator you will be involved with axios with some administrative responsibilities. This guide will help you understand your role and the responsibilities that come with being a collaborator. - -1. __Adhere to and help enforce the Code of Conduct.__ It is expected that you have read the [code of conduct](https://github.com/axios/axios/blob/master/CODE_OF_CONDUCT.md) and that you agree to live by it. This community should be friendly and welcoming. - -1. __Triage issues.__ As a collaborator you may help sort through the issues that are reported. Issues vary from bugs, regressions, feature requests, questions, etc. Apply the appropriate label(s) and respond as needed. If it is a legitimate request please address it, otherwise feel free to close the issue and include a comment with a suggestion on where to find support. If an issue has been inactive for more than a week (i.e, the owner of the issue hasn’t responded to you), close the issue with a note indicating stales issues are closed; it can always be reopened if needed. In the case of issues that require a code change encourage the owner to submit a PR. For less complex code changes, add a very simple and detailed checklist, apply the “first-timers-only” label, and encourage a newcomer to open source to get involved. - -1. __Answer questions.__ It is not expected that you provide answers to questions that aren’t relevant, nor do you need to mentor people on how to use JavaScript, etc. If the question is not directly about the module, please close the issue. If the question stems from poor documentation, please update the docs and consider adding a code example. In any event try to be helpful and remember that there’s no such thing as a stupid question. - -1. __Assist with PRs.__ By encouraging contributors to supply a PR for their own issue this is ideally where most of your attention will be focused. Keep a few things in mind as you review PRs. - - When fixing a bug: does the PR adequately solve the problem without introducing any regressions? - - When implementing a feature: does the feature fit within the scope of axios? - - When removing functionality: is it properly deprecated with a warning? - - When introducing functionality: is the API predictable? - - Does the new code work for all supported platforms/browsers? - - Do the tests and linting pass CI? - - Are there tests to validate the changes that have been made? - -1. __Fix bugs and implement features.__ When things need to be fixed or implemented and a PR can’t wait, you may do things yourself. You should still submit a PR yourself and get it checked off by at least one other contributor. Keep the points from number 4 in consideration as you push your code. - -Thank you again for your help as a collaborator and in making axios community great! If you have any questions, or need any assistance please feel free to contact another collaborator or the owner. - diff --git a/COOKBOOK.md b/COOKBOOK.md deleted file mode 100644 index 3e719b4f57..0000000000 --- a/COOKBOOK.md +++ /dev/null @@ -1,126 +0,0 @@ -# Cookbook - -In an effort to keep axios as light weight as possible, and to avoid a rats nest of code for supporting every possible integration, it is often necessary to say no to feature requests. This doesn't mean that those use cases aren't legitimate, but rather that they are easily supported by augmenting axios with other libraries. - -The following are the recipes for some of the commonly requested features. - -### Promise.prototype.done - -```bash -$ npm install axios promise --save -``` - -```js -const axios = require('axios'); -require('promise/polyfill-done'); - -axios - .get('http://www.example.com/user') - .then((response) => { - console.log(response.data); - return response; - }) - .done(); -``` - -### Promise.prototype.finally - -```bash -$ npm install axios promise.prototype.finally --save -``` - -```js -const axios = require('axios'); -require('promise.prototype.finally').shim(); - -axios - .get('http://www.example.com/user') - .then((response) => { - console.log(response.data); - return response; - }) - .finally(() => { - console.log('this will always be called'); - }); -``` - -### Inflate/Deflate - -```bash -$ npm install axios pako --save -``` - -```js -// client.js -const axios = require('axios'); -const pako = require('pako'); - -const user = { - firstName: 'Fred', - lastName: 'Flintstone' -}; - -const data = pako.deflate(JSON.stringify(user), { to: 'string' }); - -axios - .post('http://127.0.0.1:3333/user', data) - .then((response) => { - response.data = JSON.parse(pako.inflate(response.data, { to: 'string' })); - console.log(response.data); - return response; - }); -``` - -```js -// server.js -const pako = require('pako'); -const http = require('http'); -const url = require('url'); - -const server = http.createServer((req, res) => { - req.setEncoding('utf8'); - - const parsed = url.parse(req.url, true); - const pathname = parsed.pathname; - - if (pathname === '/user') { - let data = ''; - req.on('data', (chunk) => { - data += chunk; - }); - - req.on('end', () => { - const user = JSON.parse(pako.inflate(data, { to: 'string' })); - console.log(user); - - res.writeHead(200, { - 'Content-Type': 'application/json' - }); - res.end(pako.deflate(JSON.stringify({result: 'success'}), { to: 'string' })); - }); - } else { - res.writeHead(404); - res.end(pako.deflate(JSON.stringify({result: 'error'}), { to: 'string' })); - } -}); - -server.listen(3333); -``` - -### JSONP - -```bash -$ npm install jsonp --save -``` - -```js -const jsonp = require('jsonp'); - -jsonp('http://www.example.com/foo', null, (err, data) => { - if (err) { - console.error(err.message); - } else { - console.log(data); - } -}); -``` diff --git a/ECOSYSTEM.md b/ECOSYSTEM.md deleted file mode 100644 index 77bf978dae..0000000000 --- a/ECOSYSTEM.md +++ /dev/null @@ -1,26 +0,0 @@ -# Ecosystem - -This is a list of axios related libraries and resources. If you have a suggestion on what to add, please don't hesitate to submit a PR. - -## Libraries - -* [react-hooks-axios](https://github.com/use-hooks/react-hooks-axios) - Custom React Hooks for Axios.js -* [moxios](https://github.com/axios/moxios) - Mock axios requests for testing -* [axios-response-logger](https://github.com/srph/axios-response-logger) - Axios interceptor which logs responses -* [axios-mock-adapter](https://github.com/ctimmerm/axios-mock-adapter) — Axios adapter that allows to easily mock requests -* [redux-axios-middleware](https://github.com/svrcekmichal/redux-axios-middleware) - Redux middleware for fetching data with axios HTTP client -* [axios-vcr](https://github.com/nettofarah/axios-vcr) - 📼 Record and Replay Axios requests -* [@3846masa/axios-cookiejar-support](https://github.com/3846masa/axios-cookiejar-support) - Add tough-cookie support to axios -* [axios-debug-log](https://github.com/Gerhut/axios-debug-log) - Axios interceptor of logging requests & responses by debug. -* [axios-method-override](https://github.com/jacobbuck/axios-method-override) - Axios http request method override plugin -* [mocha-axios](https://github.com/jdrydn/mocha-axios) - Streamlined integration testing with Mocha & Axios -* [axiosist](https://github.com/Gerhut/axiosist) - Axios based supertest: convert node.js request handler to axios adapter, used for node.js server unit test. -* [axios-cache-plugin](https://github.com/jin5354/axios-cache-plugin) - Help you cache GET request when using axios. -* [axios-extensions](https://github.com/kuitos/axios-extensions) - A collection of axios extensions, including throttle and cache GET request plugin. -* [redux-saga-requests](https://github.com/klis87/redux-saga-requests) - Redux-Saga addon to simplify handling of AJAX requests. -* [axios-fetch](https://github.com/lifeomic/axios-fetch) - A WebAPI Fetch implementation backed by an Axios client -* [axios-curlirize](https://www.npmjs.com/package/axios-curlirize) - Logs axios requests as curl commands, also adds a property to the response object with the curl command as value. -* [axios-actions](https://github.com/davestewart/axios-actions) - Bundle endpoints as callable, reusable services -* [axios-api-versioning](https://weffe.github.io/axios-api-versioning) - Add easy to manage api versioning to axios -* [r2curl](https://github.com/uyu423/r2curl) - Extracts the cURL command string from the Axios object. (AxiosResponse, AxiosRequestConfig) -* [axios-endpoints](https://github.com/renancaraujo/axios-endpoints) - Axios endpoints helps you to create a more concise endpoint mapping with axios. diff --git a/UPGRADE_GUIDE.md b/UPGRADE_GUIDE.md deleted file mode 100644 index eedb049255..0000000000 --- a/UPGRADE_GUIDE.md +++ /dev/null @@ -1,162 +0,0 @@ -# Upgrade Guide - -### 0.15.x -> 0.16.0 - -#### `Promise` Type Declarations - -The `Promise` type declarations have been removed from the axios typings in favor of the built-in type declarations. If you use axios in a TypeScript project that targets `ES5`, please make sure to include the `es2015.promise` lib. Please see [this post](https://blog.mariusschulz.com/2016/11/25/typescript-2-0-built-in-type-declarations) for details. - -### 0.13.x -> 0.14.0 - -#### TypeScript Definitions - -The axios TypeScript definitions have been updated to match the axios API and use the ES2015 module syntax. - -Please use the following `import` statement to import axios in TypeScript: - -```typescript -import axios from 'axios'; - -axios.get('/foo') - .then(response => console.log(response)) - .catch(error => console.log(error)); -``` - -#### `agent` Config Option - -The `agent` config option has been replaced with two new options: `httpAgent` and `httpsAgent`. Please use them instead. - -```js -{ - // Define a custom agent for HTTP - httpAgent: new http.Agent({ keepAlive: true }), - // Define a custom agent for HTTPS - httpsAgent: new https.Agent({ keepAlive: true }) -} -``` - -#### `progress` Config Option - -The `progress` config option has been replaced with the `onUploadProgress` and `onDownloadProgress` options. - -```js -{ - // Define a handler for upload progress events - onUploadProgress: function (progressEvent) { - // ... - }, - - // Define a handler for download progress events - onDownloadProgress: function (progressEvent) { - // ... - } -} -``` - -### 0.12.x -> 0.13.0 - -The `0.13.0` release contains several changes to custom adapters and error handling. - -#### Error Handling - -Previous to this release an error could either be a server response with bad status code or an actual `Error`. With this release Promise will always reject with an `Error`. In the case that a response was received, the `Error` will also include the response. - -```js -axios.get('/user/12345') - .catch((error) => { - console.log(error.message); - console.log(error.code); // Not always specified - console.log(error.config); // The config that was used to make the request - console.log(error.response); // Only available if response was received from the server - }); -``` - -#### Request Adapters - -This release changes a few things about how request adapters work. Please take note if you are using your own custom adapter. - -1. Response transformer is now called outside of adapter. -2. Request adapter returns a `Promise`. - -This means that you no longer need to invoke `transformData` on response data. You will also no longer receive `resolve` and `reject` as arguments in your adapter. - -Previous code: - -```js -function myAdapter(resolve, reject, config) { - var response = { - data: transformData( - responseData, - responseHeaders, - config.transformResponse - ), - status: request.status, - statusText: request.statusText, - headers: responseHeaders - }; - settle(resolve, reject, response); -} -``` - -New code: - -```js -function myAdapter(config) { - return new Promise(function (resolve, reject) { - var response = { - data: responseData, - status: request.status, - statusText: request.statusText, - headers: responseHeaders - }; - settle(resolve, reject, response); - }); -} -``` - -See the related commits for more details: -- [Response transformers](https://github.com/axios/axios/commit/10eb23865101f9347570552c04e9d6211376e25e) -- [Request adapter Promise](https://github.com/axios/axios/commit/157efd5615890301824e3121cc6c9d2f9b21f94a) - -### 0.5.x -> 0.6.0 - -The `0.6.0` release contains mostly bug fixes, but there are a couple things to be aware of when upgrading. - -#### ES6 Promise Polyfill - -Up until the `0.6.0` release ES6 `Promise` was being polyfilled using [es6-promise](https://github.com/jakearchibald/es6-promise). With this release, the polyfill has been removed, and you will need to supply it yourself if your environment needs it. - -```js -require('es6-promise').polyfill(); -var axios = require('axios'); -``` - -This will polyfill the global environment, and only needs to be done once. - -#### `axios.success`/`axios.error` - -The `success`, and `error` aliases were deprectated in [0.4.0](https://github.com/axios/axios/blob/master/CHANGELOG.md#040-oct-03-2014). As of this release they have been removed entirely. Instead please use `axios.then`, and `axios.catch` respectively. - -```js -axios.get('some/url') - .then(function (res) { - /* ... */ - }) - .catch(function (err) { - /* ... */ - }); -``` - -#### UMD - -Previous versions of axios shipped with an AMD, CommonJS, and Global build. This has all been rolled into a single UMD build. - -```js -// AMD -require(['bower_components/axios/dist/axios'], function (axios) { - /* ... */ -}); - -// CommonJS -var axios = require('axios/dist/axios'); -```