I am currently working on a snackbar feature that receives notifications from a Web Service and displays whether the Job Execution was successful or failed.
To parse the JSON data, I have implemented the following code:
this.messageService.messageReceived$.subscribe(data => {
this.snakbar.statusBar("Platform job Completed - " + data, "Info");
let webService: WebService = JSON.parse(data);
console.log(webService.message);
console.log(webService.executionId);
console.log(webService.code);
this.spinner.hide();
this.selectedIndex = 1;
}
In order to properly parse the JSON data, I have created an Interface as follows:
interface WebService {
jobId: string,
executionId: string,
code: number,
message: string,
data: string
}
Although I can view the data in the console using console.log, I am facing an issue with displaying the message in the snackbar. Currently, I am getting
'Platform job Completed - [Object][Object]'
, but I aim to display something like 'Platform job Completed - Success/Failure Info"'
in the snackbar.
Any suggestions on how I can achieve this?