nuxt-glorious 0.7.9-7 → 0.7.9-9
Sign up to get free protection for your applications and to get access to all the features.
package/dist/module.json
CHANGED
@@ -10,6 +10,7 @@ const defaultOptions = {
|
|
10
10
|
headers: {
|
11
11
|
Accept: "application/json"
|
12
12
|
},
|
13
|
+
bodyType: "normal",
|
13
14
|
body: {},
|
14
15
|
credentials: "same-origin"
|
15
16
|
};
|
@@ -20,26 +21,10 @@ export default function(url, options) {
|
|
20
21
|
const gKey = computeGKey(options.gKey, url);
|
21
22
|
options.params = computeParams(options.params);
|
22
23
|
options.headers = { ...options.headers, ...computeAuth() };
|
23
|
-
if (
|
24
|
+
if (options.bodyType === "formData")
|
25
|
+
options.body = computeFormData(options);
|
26
|
+
if (options.bodyType === "normal" && Object.entries(options.body).length === 0)
|
24
27
|
delete options.body;
|
25
|
-
if (Object.prototype.hasOwnProperty.call(options, "bodyType") && options.bodyType === "formData") {
|
26
|
-
const form = new FormData();
|
27
|
-
Object.entries(options.body).forEach((item) => {
|
28
|
-
if (item[1] === null)
|
29
|
-
return;
|
30
|
-
if (Object.prototype.hasOwnProperty.call(options, "fileKey") && options.fileKey.includes(item[0]))
|
31
|
-
form.append(item[0], item[1]);
|
32
|
-
else {
|
33
|
-
if (typeof item[1] === "object")
|
34
|
-
Object.entries(item[1]).forEach((nestedItem, index) => {
|
35
|
-
form.append(`${item[0]}[${index}]`, nestedItem[1]);
|
36
|
-
});
|
37
|
-
else
|
38
|
-
form.append(`${item[0]}`, item[1]);
|
39
|
-
}
|
40
|
-
});
|
41
|
-
options.body = form;
|
42
|
-
}
|
43
28
|
const opt = {
|
44
29
|
...options,
|
45
30
|
onRequest() {
|
@@ -105,3 +90,18 @@ function computeAuth() {
|
|
105
90
|
header.Authorization = "Bearer " + token.value;
|
106
91
|
return header;
|
107
92
|
}
|
93
|
+
function computeFormData(options) {
|
94
|
+
const form = new FormData();
|
95
|
+
Object.entries(options.body).forEach((item) => {
|
96
|
+
if (item[1] === null)
|
97
|
+
return;
|
98
|
+
if (typeof item[1] === "object" && typeof item[1].lastModifiedDate === "undefined")
|
99
|
+
Object.entries(item[1]).forEach((nestedItem, index) => {
|
100
|
+
form.append(`${item[0]}[${index}]`, nestedItem[1]);
|
101
|
+
});
|
102
|
+
else {
|
103
|
+
form.append(`${item[0]}`, item[1]);
|
104
|
+
}
|
105
|
+
});
|
106
|
+
return form;
|
107
|
+
}
|
package/package.json
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
{
|
2
|
-
"version": "0.7.9-
|
2
|
+
"version": "0.7.9-9",
|
3
3
|
"name": "nuxt-glorious",
|
4
4
|
"description": "This package provides many things needed by a project, including server requests and authentication, SEO and other requirements of a project.",
|
5
5
|
"repository": "sajadhzj/nuxt-glorious",
|