mirror of
https://github.com/tenrok/axios.git
synced 2026-06-14 18:42:33 +03:00
Splitting progress event handlers into upload and download handlers
This commit is contained in:
committed by
Nick Uraltsev
parent
59080e68d9
commit
63f41b53aa
+8
-6
@@ -142,14 +142,16 @@ module.exports = function xhrAdapter(config) {
|
||||
}
|
||||
|
||||
// Handle progress if needed
|
||||
if (typeof config.progress === 'function') {
|
||||
if (config.method === 'post' || config.method === 'put') {
|
||||
request.upload.addEventListener('progress', config.progress);
|
||||
} else if (config.method === 'get') {
|
||||
request.addEventListener('progress', config.progress);
|
||||
}
|
||||
if (typeof config.onDownloadProgress === 'function') {
|
||||
request.addEventListener('progress', config.onDownloadProgress);
|
||||
}
|
||||
|
||||
// Not all browsers support upload events
|
||||
if (typeof config.onUploadProgress === 'function' && request.upload) {
|
||||
request.upload.addEventListener('progress', config.onUploadProgress);
|
||||
}
|
||||
|
||||
|
||||
if (requestData === undefined) {
|
||||
requestData = null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user