Skip to content

Commit

Permalink
(fix) fix data field parsing for body data
Browse files Browse the repository at this point in the history
  • Loading branch information
NikhilShahi committed Aug 26, 2022
1 parent 450c3b3 commit 28cd32b
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions backend/src/services/data-field/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,13 @@ export class DataFieldService {
body: string,
apiEndpoint: ApiEndpoint
): Promise<void> {
if (body) {
const jsonBody = parsedJson(body);
if (jsonBody) {
if (!body) {
return;
}
const jsonBody = parsedJson(body);
if (jsonBody) {
const dataType = getDataType(jsonBody);
if (dataType === DataType.OBJECT) {
for (let key in jsonBody) {
await this.recursiveParseJson(
key,
Expand All @@ -138,9 +142,13 @@ export class DataFieldService {
apiEndpoint
);
}
} else {
await this.recursiveParseJson("", dataSection, body, apiEndpoint);
} else if (dataType === DataType.ARRAY) {
for (let item of jsonBody) {
await this.recursiveParseJson("", dataSection, item, apiEndpoint);
}
}
} else {
await this.recursiveParseJson("", dataSection, body, apiEndpoint);
}
}

Expand Down

0 comments on commit 28cd32b

Please sign in to comment.