My Angular application received response from server in JSON format. I convert the response into a model like follows
let questionListSubscription = this.questionManagementService.questionsArray$.subscribe((result: Result) => {
console.log("received result from question array observable", result);
if (result.result === "success") {
//received response from server
let questionList = JSON.parse(result.additionalInfo) as PracticeQuestionsListAPI;
console.log("got list of questions value ", questionList);
//...
this.questionsFilter["pagination-info"] = questionList["pagination-info"];
//...
}
}
);
The above randomly crashed with error ERROR TypeError: Cannot set property 'pagination-info' of undefined
pointing to line this.questionsFilter['pagination-info'] = questionList['pagination-info'];
When I ran the code again, it worked.
Is the above assignment wrong and could potentially lead to memory leak?