mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Move FormDataToObject() to inline code
This commit is contained in:
parent
8e204409f6
commit
4bf1fa9f86
1 changed files with 12 additions and 13 deletions
25
dev/bootstrap.js
vendored
25
dev/bootstrap.js
vendored
|
|
@ -4,18 +4,6 @@ import { i18n } from 'Common/Translator';
|
||||||
import { root } from 'Common/Links';
|
import { root } from 'Common/Links';
|
||||||
|
|
||||||
import { isArray } from 'Common/Utils';
|
import { isArray } from 'Common/Utils';
|
||||||
const FormDataToObject = formData => {
|
|
||||||
var object = {};
|
|
||||||
formData.forEach((value, key) => {
|
|
||||||
if (!Reflect.has(object, key)){
|
|
||||||
object[key] = value;
|
|
||||||
} else {
|
|
||||||
isArray(object[key]) || (object[key] = [object[key]]);
|
|
||||||
object[key].push(value);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return object;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default App => {
|
export default App => {
|
||||||
|
|
||||||
|
|
@ -57,7 +45,18 @@ export default App => {
|
||||||
if (postData) {
|
if (postData) {
|
||||||
init.method = 'POST';
|
init.method = 'POST';
|
||||||
init.headers['Content-Type'] = 'application/json';
|
init.headers['Content-Type'] = 'application/json';
|
||||||
postData = (postData instanceof FormData) ? FormDataToObject(postData) : postData;
|
if (postData instanceof FormData) {
|
||||||
|
const object = {};
|
||||||
|
postData.forEach((value, key) => {
|
||||||
|
if (!Reflect.has(object, key)){
|
||||||
|
object[key] = value;
|
||||||
|
} else {
|
||||||
|
isArray(object[key]) || (object[key] = [object[key]]);
|
||||||
|
object[key].push(value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
postData = object;
|
||||||
|
}
|
||||||
postData.XToken = Settings.app('token');
|
postData.XToken = Settings.app('token');
|
||||||
init.body = JSON.stringify(postData);
|
init.body = JSON.stringify(postData);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue