mirror of
https://github.com/tenrok/axios.git
synced 2026-06-14 18:42:33 +03:00
Resolving merge conflicts
This commit is contained in:
@@ -257,7 +257,13 @@ These are the available config options for making requests. Only the `url` is re
|
|||||||
xsrfCookieName: 'XSRF-TOKEN', // default
|
xsrfCookieName: 'XSRF-TOKEN', // default
|
||||||
|
|
||||||
// `xsrfHeaderName` is the name of the http header that carries the xsrf token value
|
// `xsrfHeaderName` is the name of the http header that carries the xsrf token value
|
||||||
xsrfHeaderName: 'X-XSRF-TOKEN' // default
|
xsrfHeaderName: 'X-XSRF-TOKEN', // default
|
||||||
|
|
||||||
|
// `progress` allows handling of progress events for 'POST' and 'PUT uploads'
|
||||||
|
// as well as 'GET' downloads
|
||||||
|
progress: function(progressEvent) {
|
||||||
|
// Do whatever you want with the native progress event
|
||||||
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,13 @@
|
|||||||
data.append('foo', 'bar');
|
data.append('foo', 'bar');
|
||||||
data.append('file', document.getElementById('file').files[0]);
|
data.append('file', document.getElementById('file').files[0]);
|
||||||
|
|
||||||
axios.put('/upload/server', data)
|
var config = {
|
||||||
|
progress: function(progressEvent) {
|
||||||
|
var percentCompleted = progressEvent.loaded / progressEvent.total;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
axios.put('/upload/server', data, config)
|
||||||
.then(function (res) {
|
.then(function (res) {
|
||||||
output.className = 'container';
|
output.className = 'container';
|
||||||
output.innerHTML = res.data;
|
output.innerHTML = res.data;
|
||||||
@@ -40,4 +46,3 @@
|
|||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|||||||
@@ -151,6 +151,15 @@ module.exports = function xhrAdapter(resolve, reject, config) {
|
|||||||
requestData = new DataView(requestData);
|
requestData = new DataView(requestData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Clean up request
|
// Clean up request
|
||||||
requestData = (requestData === undefined)
|
requestData = (requestData === undefined)
|
||||||
? null
|
? null
|
||||||
|
|||||||
Reference in New Issue
Block a user