mirror of
https://github.com/knadh/listmonk.git
synced 2025-02-25 23:06:17 +08:00
Fix automatic field camel casing for subscriber attribs
This commit is contained in:
parent
4e5e466b03
commit
1df827c58a
1 changed files with 12 additions and 11 deletions
|
@ -41,19 +41,20 @@ http.interceptors.response.use((resp) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resp.config.preserveCase && resp.config.preserveResultsCase) {
|
if (resp.config.preserveCase && resp.config.preserveResultsCase) {
|
||||||
resp.data.data.results.forEach((r, n) => {
|
// For each key in preserveResultsCase, get the values out in an array of arrays
|
||||||
// Only preserve case for certain keys under the 'results' key.
|
// and save them as stringified JSON.
|
||||||
const save = {};
|
const save = resp.data.data.results.map(
|
||||||
resp.config.preserveResultsCase.forEach((key) => {
|
(r) => resp.config.preserveResultsCase.map((k) => JSON.stringify(r[k])),
|
||||||
save[key] = JSON.stringify(r[key]);
|
);
|
||||||
});
|
|
||||||
|
|
||||||
const item = humps.camelizeKeys(r);
|
// Camelcase everything.
|
||||||
Object.keys(save).forEach((key) => {
|
data = humps.camelizeKeys(resp.data.data);
|
||||||
item[key] = JSON.parse(save[key]);
|
|
||||||
});
|
|
||||||
|
|
||||||
data.results[n] = item;
|
// Put the saved results back.
|
||||||
|
data.results.forEach((r, n) => {
|
||||||
|
resp.config.preserveResultsCase.forEach((k, i) => {
|
||||||
|
data.results[n][k] = JSON.parse(save[n][i]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue