Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'params' of undefined #232

Open
recidive opened this issue Jan 9, 2019 · 1 comment
Open

Cannot read property 'params' of undefined #232

recidive opened this issue Jan 9, 2019 · 1 comment

Comments

@recidive
Copy link

recidive commented Jan 9, 2019

TypeError: Cannot read property 'params' of undefined
at impl (/.../node_modules/mailgun-js/lib/build.js:42:16)
at callback (/.../node_modules/promisify-call/index.js:32:8)
at /.../node_modules/with-callback/index.js:39:7
at new Promise ()
at withCallback (/.../node_modules/with-callback/index.js:5:10)
at promisifyCall (/.../node_modules/promisify-call/index.js:28:10)
at promisifed (/.../node_modules/mailgun-js/lib/build.js:105:14)
at post (/.../src/handlers.js:39:3)
at
at process._tickCallback (internal/process/next_tick.js:188:7)

  1. What version of the module is the issue happening on? Does the issue happen on latest version?
    0.22.0

  2. What platform and Node.js version? (For example Node.js 6.9.1 on Mac OS X)

8.10.0

  1. Does the action work when you manually perform request against mailgun using curl (or other means)?

Yes

  1. Sample source code or steps to reproduce
const mailgun = require('mailgun-js')

const sendMail = mailgun({
  apiKey: MAILGUN_API_KEY,
  domain: MAILGUN_DOMAIN,
}).messages().send

const payload = {
  from,
  to,
  subject,
  text,
}

await sendMail(payload)

(Write description of your issue here, stack traces from errors and code that reproduces the issue are helpful)

@craigmichaelmartin
Copy link

Hi @recidive - this is a generic (much despised) javascript "foot-gun". When you assign the send function to a variable, and call it later standalone, it is called unbound from the mailgun instance. For example, const qs = document.querySelector; qs('this.will.error'); If you bind the function though const qs = document.querySelector.bind(document); qs('all.is.well');

You could leave the issue open if your desire is to explore mailgun-js binding it's functions to accommodate this usage; otherwise, binding your send method resolves the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants