11/**
22 * @description
3- * HTTP code snippet generator for native XMLHttpRequest
3+ * HTTP code snippet generator for native Protocol Engine
44 *
55 * @author
6- * @AhmadNassri
6+ * @lttlrck
77 *
8- * for any questions or issues regarding the generated code snippet, please open an issue mentioning the author.
98 */
109
1110'use strict'
@@ -28,46 +27,7 @@ module.exports = function (source, options) {
2827 headers : source . allHeaders
2928 }
3029
31- switch ( source . postData . mimeType ) {
32- case 'application/x-www-form-urlencoded' :
33- settings . data = source . postData . paramsObj ? source . postData . paramsObj : source . postData . text
34- break
35-
36- case 'application/json' :
37- settings . processData = false
38- settings . data = source . postData . text
39- break
40-
41- case 'multipart/form-data' :
42- code . push ( 'var form = new FormData();' )
43-
44- source . postData . params . forEach ( function ( param ) {
45- code . push ( 'form.append(%s, %s);' , JSON . stringify ( param . name ) , JSON . stringify ( param . value || param . fileName || '' ) )
46- } )
47-
48- settings . processData = false
49- settings . contentType = false
50- settings . mimeType = 'multipart/form-data'
51- settings . data = '[form]'
52-
53- // remove the contentType header
54- if ( ~ settings . headers [ 'content-type' ] . indexOf ( 'boundary' ) ) {
55- delete settings . headers [ 'content-type' ]
56- }
57- code . blank ( )
58- break
59-
60- default :
61- if ( source . postData . text ) {
62- settings . data = source . postData . text
63- }
64- }
65-
66- code . push ( 'var settinsdffdsdffsdsfdgs = ' + JSON . stringify ( settings , null , opts . indent ) . replace ( '"[form]"' , 'form' ) )
67- . blank ( )
68- . push ( '$.ajax(settings).done(function (response) {' )
69- . push ( 1 , 'console.log(response);' )
70- . push ( '});' )
30+ code . push ( '@output("dataReq", { method:"' + source . method + '", path:"' + source . fullurl + '", timeout: 3000 }, "lower");' )
7131
7232 return code . join ( )
7333}
0 commit comments