surround redirect check in try/catch

based on the suggestion by @rschamp!
This commit is contained in:
Matthew Taylor 2016-01-20 08:36:05 -05:00
parent 2e79a5aa6b
commit e85563c96e

View file

@ -44,7 +44,11 @@ var Api = {
if (err) log.error(err);
// Legacy API responses come as lists, and indicate to redirect the client like
// [{success: true, redirect: "/location/to/redirect"}]
if (body && body[0] && 'redirect' in body[0]) window.location = body[0].redirect;
try {
if (body && body[0] && 'redirect' in body[0]) window.location = body[0].redirect;
} catch (err) {
// do nothing
}
callback(err, body);
});
}.bind(this);