Open jhurliman opened 6 years ago
That should only happen when the MyQ server is no responsive
RIght. The promise chain needs an error handler on the end of it for that situation. In future versions of Node, an unhandled exception in a promise will terminate the process.
Is there a reason you just don't do this to prevent the crash?
fetch("https://myqexternal.myqdevice.com/api/v4/User/Validate", {
method: "POST",
headers: HEADERS,
body: JSON.stringify(body)
}).then(function (res) {
return res.json();
}, function (error) {
return { ReturnCode: 1, ErrorMessage: 'Unable to Validate User' }
}).then(function (data) {
// Check for MyQ Error Codes
if (data.ReturnCode === "0") {
self.securityToken = data.SecurityToken;
self.manufacturer = "Chamberlain";
self.getDevice(callback);
} else {
self.log(data.ErrorMessage);
callback(data.ErrorMessage);
}
});