Sfoglia il codice sorgente

updated lu request to handle FormData object

tags/v0.5.0
Robin Thoni 7 anni fa
parent
commit
fd7f040578
1 ha cambiato i file con 9 aggiunte e 4 eliminazioni
  1. 9
    4
      src/DataAccess/lu-request.js

+ 9
- 4
src/DataAccess/lu-request.js Vedi File

82
                     url: url,
82
                     url: url,
83
                     method: method,
83
                     method: method,
84
                     params: dataGet,
84
                     params: dataGet,
85
-                    data: JSON.stringify(dataPost),
86
-                    headers: {
87
-                        'Content-Type': "application/json"
88
-                    }
85
+                    headers: {}
89
                 };
86
                 };
87
+                if (dataPost != null && dataPost.constructor === FormData) {
88
+                    params.data = dataPost;
89
+                    params.headers['Content-Type'] = undefined;
90
+                }
91
+                else {
92
+                    params.data = JSON.stringify(dataPost);
93
+                    params.headers['Content-Type'] = 'application/json';
94
+                }
90
 
95
 
91
                 for (var i = 0; i < luRequest.hooks.before.length; ++i) {
96
                 for (var i = 0; i < luRequest.hooks.before.length; ++i) {
92
                     luRequest.hooks.before[i](url, method, dataGet, dataPost, luBusyGroups);
97
                     luRequest.hooks.before[i](url, method, dataGet, dataPost, luBusyGroups);

Loading…
Annulla
Salva