Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
inthemill committed Jul 20, 2017
2 parents 24ecb51 + f1fb3de commit bdcad15
Show file tree
Hide file tree
Showing 36 changed files with 368 additions and 151 deletions.
26 changes: 26 additions & 0 deletions .github/ISSUE_TEMPLATE.md
@@ -0,0 +1,26 @@
<!-- Click "Preview" for a more readable version -->

#### Instructions

Please read and follow this instructions before submitting an issue:

- Read all our documentation, specially the [README](https://github.com/mzabriskie/axios/blob/master/README.md). It may contain information that helps you solve your issue.
- Ensure your issue isn't already [reported](https://github.com/mzabriskie/axios/issues?utf8=%E2%9C%93&q=is%3Aissue).
- If you aren't sure that the issue is caused by axios or you just need for help, please use [Stack Overflow](https://stackoverflow.com/questions/tagged/axios) or [our chat](https://gitter.im/mzabriskie/axios).
- If you're reporting a bug, ensure it isn't already fixed in the latest axios version.
- If you need a new feature there's a chance it's already implemented in a [library](https://github.com/mzabriskie/axios/blob/master/ECOSYSTEM.md) or you can implement it using [interceptors](https://github.com/mzabriskie/axios#interceptors).

*^^^ Delete the instructions before submitting the issue ^^^*

#### Summary

Describe your issue here, including as much detail as necessary.

If you're reporting a bug, include the relevant code and stack traces to debug it (removing any private information).

If you're requesting a feature, include some context and examples of code using it.

#### Context

- axios version: *e.g.: v0.16.0*
- Environment: *e.g.: node v6.9.4, chrome 54, windows 7*
13 changes: 13 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,13 @@
<!-- Click "Preview" for a more readable version -->

#### Instructions

Please read and follow this instructions before creating and submitting a pull request:

- Create an issue explaining the feature. It could save you some effort in case we don't consider it should be included in axios.
- If you're fixing a bug, try to commit the failing test/s and the code fixing it in different commits.
- Ensure you're following our [contributing guide](https://github.com/mzabriskie/axios/blob/master/CONTRIBUTING.md).

*^^^ Delete the instructions before submitting the pull request ^^^*

Describe your pull request here.
21 changes: 21 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,26 @@
# Changelog

### 0.16.2 (Jun 3, 2017)

- Fixing issue with including `buffer` in bundle ([#887](https://github.com/mzabriskie/axios/pull/887))
- Including underlying request in errors ([#830](https://github.com/mzabriskie/axios/pull/830))
- Convert `method` to lowercase ([#930](https://github.com/mzabriskie/axios/pull/930))

### 0.16.1 (Apr 8, 2017)

- Improving HTTP adapter to return last request in case of redirects ([#828](https://github.com/mzabriskie/axios/pull/828))
- Updating `follow-redirects` dependency ([#829](https://github.com/mzabriskie/axios/pull/829))
- Adding support for passing `Buffer` in node ([#773](https://github.com/mzabriskie/axios/pull/773))

### 0.16.0 (Mar 31, 2017)

- **BREAKING** Removing `Promise` from axios typings in favor of built-in type declarations ([#480](https://github.com/mzabriskie/axios/issues/480))
- Adding `options` shortcut method ([#461](https://github.com/mzabriskie/axios/pull/461))
- Fixing issue with using `responseType: 'json'` in browsers incompatible with XHR Level 2 ([#654](https://github.com/mzabriskie/axios/pull/654))
- Improving React Native detection ([#731](https://github.com/mzabriskie/axios/pull/731))
- Fixing `combineURLs` to support empty `relativeURL` ([#581](https://github.com/mzabriskie/axios/pull/581))
- Removing `PROTECTION_PREFIX` support ([#561](https://github.com/mzabriskie/axios/pull/561))

### 0.15.3 (Nov 27, 2016)

- Fixing issue with custom instances and global defaults ([#443](https://github.com/mzabriskie/axios/issues/443))
Expand Down
2 changes: 2 additions & 0 deletions ECOSYSTEM.md
Expand Up @@ -10,3 +10,5 @@ This is a list of axios related libraries and resources. If you have a suggestio
* [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
13 changes: 8 additions & 5 deletions Gruntfile.js
Expand Up @@ -11,12 +11,15 @@ module.exports = function(grunt) {
dist: 'dist/**'
},

typings: {
install: {}
},

ts: {
test: {
options: {
lib: [
'es5',
'es2015.promise',
'dom'
]
},
src: ['typings/index.d.ts', 'test/typescript/*.ts']
}
},
Expand Down Expand Up @@ -93,7 +96,7 @@ module.exports = function(grunt) {
grunt.file.write('bower.json', JSON.stringify(bower, null, 2));
});

grunt.registerTask('test', 'Run the jasmine and nodeunit tests', ['eslint', 'nodeunit', 'karma:single', 'typings', 'ts']);
grunt.registerTask('test', 'Run the jasmine and nodeunit tests', ['eslint', 'nodeunit', 'karma:single', 'ts']);
grunt.registerTask('build', 'Run webpack and bundle the source', ['clean', 'webpack']);
grunt.registerTask('version', 'Sync version info for a release', ['usebanner', 'package2bower']);
};
56 changes: 42 additions & 14 deletions README.md
Expand Up @@ -21,7 +21,7 @@ Promise based HTTP client for the browser and node.js

## Browser Support

![Chrome](https://raw.github.com/alrra/browser-logos/master/chrome/chrome_48x48.png) | ![Firefox](https://raw.github.com/alrra/browser-logos/master/firefox/firefox_48x48.png) | ![Safari](https://raw.github.com/alrra/browser-logos/master/safari/safari_48x48.png) | ![Opera](https://raw.github.com/alrra/browser-logos/master/opera/opera_48x48.png) | ![Edge](https://raw.github.com/alrra/browser-logos/master/edge/edge_48x48.png) | ![IE](https://raw.github.com/alrra/browser-logos/master/internet-explorer/internet-explorer_48x48.png) |
![Chrome](https://raw.github.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png) | ![Firefox](https://raw.github.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png) | ![Safari](https://raw.github.com/alrra/browser-logos/master/src/safari/safari_48x48.png) | ![Opera](https://raw.github.com/alrra/browser-logos/master/src/opera/opera_48x48.png) | ![Edge](https://raw.github.com/alrra/browser-logos/master/src/edge/edge_48x48.png) | ![IE](https://raw.github.com/alrra/browser-logos/master/src/archive/internet-explorer_9-11/internet-explorer_9-11_48x48.png) |
--- | --- | --- | --- | --- | --- |
Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | 8+ ✔ |

Expand Down Expand Up @@ -125,6 +125,18 @@ axios({
});
```

```js
// GET request for remote image
axios({
method:'get',
url:'http://bit.ly/2mTM3nY',
responseType:'stream'
})
.then(function(response) {
response.data.pipe(fs.createWriteStream('ada_lovelace.jpg'))
});
```

##### axios(url[, config])

```js
Expand All @@ -140,6 +152,7 @@ For convenience aliases have been provided for all supported request methods.
##### axios.get(url[, config])
##### axios.delete(url[, config])
##### axios.head(url[, config])
##### axios.options(url[, config])
##### axios.post(url[, data[, config]])
##### axios.put(url[, data[, config]])
##### axios.patch(url[, data[, config]])
Expand Down Expand Up @@ -176,6 +189,7 @@ The available instance methods are listed below. The specified config will be me
##### axios#get(url[, config])
##### axios#delete(url[, config])
##### axios#head(url[, config])
##### axios#options(url[, config])
##### axios#post(url[, data[, config]])
##### axios#put(url[, data[, config]])
##### axios#patch(url[, data[, config]])
Expand All @@ -199,7 +213,8 @@ These are the available config options for making requests. Only the `url` is re

// `transformRequest` allows changes to the request data before it is sent to the server
// This is only applicable for request methods 'PUT', 'POST', and 'PATCH'
// The last function in the array must return a string, an ArrayBuffer, or a Stream
// The last function in the array must return a string or an instance of Buffer, ArrayBuffer,
// FormData or Stream
transformRequest: [function (data) {
// Do whatever you want to transform the data

Expand Down Expand Up @@ -234,7 +249,7 @@ These are the available config options for making requests. Only the `url` is re
// When no `transformRequest` is set, must be of one of the following types:
// - string, plain object, ArrayBuffer, ArrayBufferView, URLSearchParams
// - Browser only: FormData, File, Blob
// - Node only: Stream
// - Node only: Stream, Buffer
data: {
firstName: 'Fred'
},
Expand All @@ -248,7 +263,7 @@ These are the available config options for making requests. Only the `url` is re
withCredentials: false, // default

// `adapter` allows custom handling of requests which makes testing easier.
// Return a promise and supply a valid response (see [response docs](#response-api)).
// Return a promise and supply a valid response (see lib/adapters/README.md).
adapter: function (config) {
/* ... */
},
Expand Down Expand Up @@ -297,18 +312,20 @@ These are the available config options for making requests. Only the `url` is re
maxRedirects: 5, // default

// `httpAgent` and `httpsAgent` define a custom agent to be used when performing http
// and https requests, respectively, in node.js. This allows to configure options like
// and https requests, respectively, in node.js. This allows options to be added like
// `keepAlive` that are not enabled by default.
httpAgent: new http.Agent({ keepAlive: true }),
httpsAgent: new https.Agent({ keepAlive: true }),

// 'proxy' defines the hostname and port of the proxy server
// `auth` indicates that HTTP Basic auth should be used to connect to the proxy, and supplies credentials.
// This will set an `Proxy-Authorization` header, overwriting any existing `Proxy-Authorization` custom headers you have set using `headers`.
// `auth` indicates that HTTP Basic auth should be used to connect to the proxy, and
// supplies credentials.
// This will set an `Proxy-Authorization` header, overwriting any existing
// `Proxy-Authorization` custom headers you have set using `headers`.
proxy: {
host: '127.0.0.1',
port: 9000,
auth: : {
auth: {
username: 'mikeymike',
password: 'rapunz3l'
}
Expand Down Expand Up @@ -337,10 +354,16 @@ The response for a request contains the following information.
statusText: 'OK',

// `headers` the headers that the server responded with
// All header names are lower cased
headers: {},

// `config` is the config that was provided to `axios` for the request
config: {}
config: {},

// `request` is the request that generated this response
// It is the last ClientRequest instance in node.js (in redirects)
// and an XMLHttpRequest instance the browser
request: {}
}
```

Expand Down Expand Up @@ -446,11 +469,16 @@ instance.interceptors.request.use(function () {/*...*/});
axios.get('/user/12345')
.catch(function (error) {
if (error.response) {
// The request was made, but the server responded with a status code
// The request was made and the server responded with a status code
// that falls out of the range of 2xx
console.log(error.response.data);
console.log(error.response.status);
console.log(error.response.headers);
} else if (error.request) {
// The request was made but no response was received
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of
// http.ClientRequest in node.js
console.log(error.request);
} else {
// Something happened in setting up the request that triggered an Error
console.log('Error', error.message);
Expand All @@ -473,7 +501,7 @@ axios.get('/user/12345', {

You can cancel a request using a *cancel token*.

> The axios cancel token API is based on the [cancelable promises proposal](https://github.com/tc39/proposal-cancelable-promises), which is currently at Stage 1.
> The axios cancel token API is based on the withdrawn [cancelable promises proposal](https://github.com/tc39/proposal-cancelable-promises).
You can create a cancel token using the `CancelToken.source` factory as shown below:

Expand Down Expand Up @@ -526,7 +554,7 @@ In a browser, you can use the [`URLSearchParams`](https://developer.mozilla.org/
var params = new URLSearchParams();
params.append('param1', 'value1');
params.append('param2', 'value2');
axios.post('/foo', params);
axios.post('/foo', params);
```

> Note that `URLSearchParams` is not supported by all browsers, but there is a [polyfill](https://github.com/WebReflection/url-search-params) available (make sure to polyfill the global environment).
Expand All @@ -535,7 +563,7 @@ Alternatively, you can encode data using the [`qs`](https://github.com/ljharb/qs

```js
var qs = require('qs');
axios.post('/foo', qs.stringify({ 'bar': 123 });
axios.post('/foo', qs.stringify({ 'bar': 123 }));
```

### Node.js
Expand All @@ -544,7 +572,7 @@ In node.js, you can use the [`querystring`](https://nodejs.org/api/querystring.h

```js
var querystring = require('querystring');
axios.post('http://something.com/', querystring.stringify({ foo: 'bar' });
axios.post('http://something.com/', querystring.stringify({ foo: 'bar' }));
```

You can also use the `qs` library.
Expand Down
6 changes: 6 additions & 0 deletions UPGRADE_GUIDE.md
@@ -1,5 +1,11 @@
# 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
Expand Down
2 changes: 1 addition & 1 deletion bower.json
@@ -1,7 +1,7 @@
{
"name": "axios",
"main": "./dist/axios.js",
"version": "0.15.3",
"version": "0.16.2",
"homepage": "https://github.com/mzabriskie/axios",
"authors": [
"Matt Zabriskie"
Expand Down

0 comments on commit bdcad15

Please sign in to comment.