File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,9 @@ grunt.initConfig({
4242 },
4343 data: {
4444 someKey: ' some value'
45+ },
46+ onComplete : function (data ) {
47+ console .log (' Response: ' + data);
4548 }
4649 },
4750 src: ' <%= yeoman.dist %>/dist.zip' ,
@@ -87,6 +90,12 @@ DefaultValue: `{}`
8790
8891Headers to send along with your HTTP request. For example, a lot of API require the Authentication to be sent through the Headers.
8992
93+ #### options.onComplete
94+ Type: ` Function `
95+ DefaultValue: ` function(data) {} `
96+
97+ Callback used to process server's response. For example, when server returns id of uploaded file you need to process afterwards.
98+
9099#### src
91100Type: ` String `
92101Default value: ` '' `
Original file line number Diff line number Diff line change @@ -23,7 +23,8 @@ module.exports = function(grunt) {
2323 rejectUnauthorized : true ,
2424 method : 'POST' ,
2525 headers : { } ,
26- url : ''
26+ url : '' ,
27+ onComplete : function ( data ) { }
2728 } ) ;
2829
2930 grunt . verbose . writeflags ( options , 'Options' ) ;
@@ -61,6 +62,7 @@ module.exports = function(grunt) {
6162 } ) . on ( 'complete' , function ( data , response ) {
6263 if ( response !== null && response . statusCode >= 200 && response . statusCode < 300 ) {
6364 grunt . log . ok ( 'Upload successful of "' + filepath + '" as "' + field + '" - ' + options . method + ' @ ' + options . url ) ;
65+ options . onComplete ( data ) ;
6466 } else if ( response !== null ) {
6567 grunt . fail . warn ( 'Failed uploading "' + filepath + '" as "' + field + '" (status code: ' + response . statusCode + ') - ' + options . method + ' @ ' + options . url ) ;
6668 } else {
You can’t perform that action at this time.
0 commit comments