SparkPost / node-sparkpost

SparkPost client library for Node.js
https://www.sparkpost.com/
Other
180 stars 42 forks source link

Preview draft option bug #233

Open avigoldman opened 6 years ago

avigoldman commented 6 years ago

Looks like we have a bug with the template preview function.

sparkpost.templates.preview('template-id', {
    substitution_data: {},
    draft: false
})

This code will actually preview the draft since the code is falsey checking the draft option. We need to update it to check if the object has the draft property, instead of if the value is truthy. Line with the issue: https://github.com/SparkPost/node-sparkpost/blob/master/lib/templates.js#L143

You can work around it by setting draft to "false" (as a string).