mirror of
https://github.com/tenrok/axios.git
synced 2026-06-20 20:00:40 +03:00
adding sample code to GET images
This commit is contained in:
@@ -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])
|
##### axios(url[, config])
|
||||||
|
|
||||||
```js
|
```js
|
||||||
@@ -526,7 +538,7 @@ In a browser, you can use the [`URLSearchParams`](https://developer.mozilla.org/
|
|||||||
var params = new URLSearchParams();
|
var params = new URLSearchParams();
|
||||||
params.append('param1', 'value1');
|
params.append('param1', 'value1');
|
||||||
params.append('param2', 'value2');
|
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).
|
> 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).
|
||||||
|
|||||||
Reference in New Issue
Block a user