@sendgrid/helpers
Advanced tools
Comparing version 7.2.6 to 7.3.0
'use strict'; | ||
/** | ||
* Dependencies | ||
*/ | ||
const chalk = require('chalk'); | ||
/** | ||
* Response error class | ||
@@ -22,3 +17,3 @@ */ | ||
//Extract data from response | ||
const {headers, status, statusText, data} = response; | ||
const { headers, status, statusText, data } = response; | ||
@@ -28,3 +23,3 @@ //Set data | ||
this.message = statusText; | ||
this.response = {headers, body: data}; | ||
this.response = { headers, body: data }; | ||
@@ -45,9 +40,9 @@ //Capture stack trace | ||
toString() { | ||
const {body} = this.response; | ||
let err = chalk.red(`${this.message} (${this.code})`); | ||
const { body } = this.response; | ||
let err = `${this.message} (${this.code})`; | ||
if (body && Array.isArray(body.errors)) { | ||
body.errors.forEach(error => { | ||
const message = chalk.yellow(error.message); | ||
const field = chalk.grey(error.field); | ||
const help = chalk.grey(error.help); | ||
const message = error.message; | ||
const field = error.field; | ||
const help = error.help; | ||
err += `\n ${message}\n ${field}\n ${help}`; | ||
@@ -63,4 +58,4 @@ }); | ||
toJSON() { | ||
const {message, code, response} = this; | ||
return {message, code, response}; | ||
const { message, code, response } = this; | ||
return { message, code, response }; | ||
} | ||
@@ -67,0 +62,0 @@ } |
{ | ||
"name": "@sendgrid/helpers", | ||
"description": "Twilio SendGrid NodeJS internal helpers", | ||
"version": "7.2.6", | ||
"version": "7.3.0", | ||
"author": "Twilio SendGrid <help@twilio.com> (sendgrid.com)", | ||
@@ -33,6 +33,5 @@ "contributors": [ | ||
"dependencies": { | ||
"chalk": "^2.0.1", | ||
"deepmerge": "^4.2.2" | ||
}, | ||
"gitHead": "017fe1a56391cfe5d74c3d432881dbdc44287d41" | ||
"gitHead": "59f6cffc3d45e702ec81212238bae7bf0d704841" | ||
} |
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
1
137796
4551
- Removedchalk@^2.0.1
- Removedansi-styles@3.2.1(transitive)
- Removedchalk@2.4.2(transitive)
- Removedcolor-convert@1.9.3(transitive)
- Removedcolor-name@1.1.3(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedhas-flag@3.0.0(transitive)
- Removedsupports-color@5.5.0(transitive)