mirror of
https://github.com/tenrok/axios.git
synced 2026-06-17 19:21:29 +03:00
Add 'progress' config option for monitoring progress events for uploads and downloads.
This commit is contained in:
@@ -11,6 +11,7 @@ var transformData = require('./../helpers/transformData');
|
||||
var urlIsSameOrigin = require('./../helpers/urlIsSameOrigin');
|
||||
|
||||
module.exports = function xhrAdapter(resolve, reject, config) {
|
||||
|
||||
// Transform request data
|
||||
var data = transformData(
|
||||
config.data,
|
||||
@@ -100,6 +101,15 @@ module.exports = function xhrAdapter(resolve, reject, config) {
|
||||
}
|
||||
}
|
||||
|
||||
// Handle progress if needed
|
||||
if (config.progress) {
|
||||
if (config.method === 'post' || config.method === 'put') {
|
||||
request.upload.addEventListener('progress', config.progress);
|
||||
} else if (config.method === 'get') {
|
||||
request.addEventListener('progress', config.progress);
|
||||
}
|
||||
}
|
||||
|
||||
if (utils.isArrayBuffer(data)) {
|
||||
data = new DataView(data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user