@radiantabyss/vue 3.3.14 → 3.3.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/Request.js +25 -0
package/package.json
CHANGED
package/src/Request.js
CHANGED
|
@@ -88,6 +88,28 @@ const buildParams = (obj, prefix = '', params = new URLSearchParams()) => {
|
|
|
88
88
|
return params;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
//recursively remove keys whose value is undefined or null so they aren't sent to the server
|
|
92
|
+
const stripEmpty = (value) => {
|
|
93
|
+
if ( Array.isArray(value) ) {
|
|
94
|
+
return value.map(stripEmpty);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if ( value !== null && typeof value === 'object' && !(value instanceof Blob) ) {
|
|
98
|
+
const cleaned = {};
|
|
99
|
+
for ( let key in value ) {
|
|
100
|
+
if ( value[key] === undefined || value[key] === null ) {
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
cleaned[key] = stripEmpty(value[key]);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return cleaned;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return value;
|
|
111
|
+
};
|
|
112
|
+
|
|
91
113
|
const request = function(method, edge, payload = {}, display_errors = false, base_url = null, auth_token = null, headers = {}, upload_progress = null) {
|
|
92
114
|
return new Promise((resolve, reject) => {
|
|
93
115
|
if ( !base_url ) {
|
|
@@ -148,6 +170,9 @@ const request = function(method, edge, payload = {}, display_errors = false, bas
|
|
|
148
170
|
current[edge] = _cancel;
|
|
149
171
|
}
|
|
150
172
|
|
|
173
|
+
//drop undefined/null keys before serializing
|
|
174
|
+
payload = stripEmpty(payload);
|
|
175
|
+
|
|
151
176
|
let data;
|
|
152
177
|
let url = base_url + edge;
|
|
153
178
|
|