0

I expect the following chain of properties (nested objects) error.response.data.errorCode on object error. How can I check that errorCode really exists? Of course - I can write the following code:

if (error.hasOwnPropert('response') {
    if (error.repsonse.hasOwnProperty('data') {
        ...
    }
}

Of course, I can also write function, that parses property name (error.response.data.errorCode) and that recursively check the existence of expected property but maybe there is already built-in and optimized function for this?

TomR
  • 2,696
  • 6
  • 34
  • 87

0 Answers0