Ver código fonte

updated lu request to handle FormData object

tags/v0.5.0
Robin Thoni 7 anos atrás
pai
commit
fd7f040578
1 arquivos alterados com 9 adições e 4 exclusões
  1. 9
    4
      src/DataAccess/lu-request.js

+ 9
- 4
src/DataAccess/lu-request.js Ver arquivo

@@ -82,11 +82,16 @@
82 82
                     url: url,
83 83
                     method: method,
84 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 96
                 for (var i = 0; i < luRequest.hooks.before.length; ++i) {
92 97
                     luRequest.hooks.before[i](url, method, dataGet, dataPost, luBusyGroups);

Carregando…
Cancelar
Salvar