As someone new to Angular, I have a function in a component that makes API calls and expects results, but errors can also occur.
this.Service.callAPI().
.subscribe(data => {
if(data?.errors){
});
The issue is arising because both data and errors can be null. This results in a cannot read property of null
error. How can I resolve this? I attempted using data?.errors?
, but it did not work.