diff options
author | Elmer Thomas <elmer@thinkingserious.com> | 2016-06-08 10:34:44 -0700 |
---|---|---|
committer | Elmer Thomas <elmer@thinkingserious.com> | 2016-06-08 10:34:44 -0700 |
commit | 15ca3f187b4fd34ab2642f94bf18a4e1e09f4fd5 (patch) | |
tree | 488a191b16d3e9aa91d611c797dd2e25f6a7e732 /lib/sendgrid.js | |
parent | 1e5f641635666857f4301c929db4cf205043b6eb (diff) | |
download | sendgrid-nodejs-15ca3f187b4fd34ab2642f94bf18a4e1e09f4fd5.zip sendgrid-nodejs-15ca3f187b4fd34ab2642f94bf18a4e1e09f4fd5.tar.gz sendgrid-nodejs-15ca3f187b4fd34ab2642f94bf18a4e1e09f4fd5.tar.bz2 |
Simplified setting the request object
Diffstat (limited to 'lib/sendgrid.js')
-rw-r--r-- | lib/sendgrid.js | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/sendgrid.js b/lib/sendgrid.js index 88ee69a..3de2fcf 100644 --- a/lib/sendgrid.js +++ b/lib/sendgrid.js @@ -1,11 +1,11 @@ "use strict"; var package_json = require('./../package.json'); +var emptyRequest = JSON.parse(JSON.stringify(require('sendgrid-rest').request)) // SendGrid allows for quick and easy access to the v3 Web API function SendGrid (apiKey, host, globalHeaders) { var Client = require('sendgrid-rest').Client - var emptyRequest = require('sendgrid-rest').request - var globalRequest = JSON.parse(JSON.stringify(emptyRequest)) + var globalRequest = emptyRequest globalRequest.host = host || "api.sendgrid.com"; globalRequest.headers['Content-Type'] = 'application/json' globalRequest.headers['Authorization'] = 'Bearer '.concat(apiKey) @@ -32,5 +32,6 @@ function SendGrid (apiKey, host, globalHeaders) { module.exports = { - SendGrid: SendGrid + SendGrid: SendGrid, + emptyRequest: emptyRequest } |