My coding challenge involves the following logic:
export const normaliseHistoryLog = history => {
if (history.children.length === 0) {
debugger;
return {
id: history.id,
date: history.timestamp,
time: history.timestamp,
event: history.event.label,
eventHTML: getHTML(history.event.detail),
source: history.source,
requestor: history.requestor
}
}
debugger;
return {
id: history.id,
date: history.timestamp,
detail: history.children.map(normaliseHistoryLog),
time: history.timestamp,
event: history.event.label,
eventHTML: getHTML(history.event.detail),
source: history.source,
requestor: history.requestor
}
}
I encountered an error message related to this line of code:
detail: history.children.map(normaliseHistoryLog),
The error indicated that 'normaliseHistoryLog' is undefined.
To troubleshoot, I experimented with the following approach:
detail: history.children.map((el) => normaliseHistoryLog(el))
However, this alternative did not resolve the issue.
This function is utilized within another function as shown below:
export const getHistory = asyncMiddleware(async (req) => {
const path = `url`;
const response = await get(req, path);
debugger;
return response.result.map(normaliseHistoryLog);
});
In this scenario, 'response.result' contains an array of objects.