Comparing version 6.4.0 to 6.4.1
@@ -196,26 +196,18 @@ "use strict"; | ||
if (response.status > 299) { | ||
return response | ||
.clone() | ||
.json() | ||
.then(function (body) { | ||
var error = new nylas_api_error_1.default(response.status, body.type, body.message); | ||
if (body.missing_fields) { | ||
error.missingFields = body.missing_fields; | ||
return response.text().then(function (body) { | ||
try { | ||
var parsedApiError = JSON.parse(body); | ||
var error = new nylas_api_error_1.default(response.status, parsedApiError.type, parsedApiError.message); | ||
if (parsedApiError.missing_fields) { | ||
error.missingFields = parsedApiError.missing_fields; | ||
} | ||
if (parsedApiError.server_error) { | ||
error.serverError = parsedApiError.server_error; | ||
} | ||
return reject(error); | ||
} | ||
if (body.server_error) { | ||
error.serverError = body.server_error; | ||
catch (e) { | ||
var error = new nylas_api_error_1.default(response.status, response.statusText, body); | ||
return reject(error); | ||
} | ||
return reject(error); | ||
}) | ||
.catch(function () { | ||
return response | ||
.text() | ||
.then(function (text) { | ||
var error = new nylas_api_error_1.default(response.status, response.statusText, text); | ||
return reject(error); | ||
}) | ||
.catch(function () { | ||
var error = new nylas_api_error_1.default(response.status, response.statusText, 'Error encountered during request, unable to extract error message.'); | ||
return reject(error); | ||
}); | ||
}); | ||
@@ -248,8 +240,10 @@ } | ||
else { | ||
return response | ||
.clone() | ||
.json() | ||
.catch(function () { return response.text(); }) | ||
.then(function (data) { return resolve(data); }) | ||
.catch(function () { return resolve(undefined); }); | ||
return response.text().then(function (text) { | ||
try { | ||
return resolve(JSON.parse(text)); | ||
} | ||
catch (e) { | ||
return resolve(text); | ||
} | ||
}); | ||
} | ||
@@ -256,0 +250,0 @@ } |
{ | ||
"name": "nylas", | ||
"version": "6.4.0", | ||
"version": "6.4.1", | ||
"description": "A NodeJS wrapper for the Nylas REST API for email, contacts, and calendar.", | ||
@@ -5,0 +5,0 @@ "main": "lib/nylas.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
373285
9509