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 call method 'match' of undefined #2

Closed
little-big-co opened this issue Apr 4, 2016 · 2 comments
Closed

Cannot call method 'match' of undefined #2

little-big-co opened this issue Apr 4, 2016 · 2 comments

Comments

@little-big-co
Copy link

Created my own ZIP as described with the provided code and added the mentioned Markup.js. However, there were some minor errors:

  1. You have to declare the AWS region if not in the standard one.
  2. There is a typo in index.js when invoking the Markup.js (Markup-js instead of Markup.js)

Once solved these it throws the "Cannot call method 'match' of undefined" error.

Here's the log:
START RequestId: 15c2b976-fa62-11e5-ae3d-eb178e7400bf Version: $LATEST 2016-04-04T12:38:08.765Z 15c2b976-fa62-11e5-ae3d-eb178e7400bf Event: {"email":"adcgn@mailinator.com","name":"Customer Name","message":"Hello World! Going to the moon!"} 2016-04-04T12:38:08.765Z 15c2b976-fa62-11e5-ae3d-eb178e7400bf Loading template from Templates/Template.html in mailtest.staticmailer.com 2016-04-04T12:38:09.405Z 15c2b976-fa62-11e5-ae3d-eb178e7400bf Template Body: ���2016-04-04T12:38:09.566Z 15c2b976-fa62-11e5-ae3d-eb178e7400bf TypeError: Cannot call method 'match' of undefined at Object.Mark.up (/var/task/markup.js:158:25) at Response.<anonymous> (/var/task/index.js:62:32) at Request.<anonymous> (/var/runtime/node_modules/aws-sdk/lib/request.js:354:18) at Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:105:20) at Request.emit (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:77:10) at Request.emit (/var/runtime/node_modules/aws-sdk/lib/request.js:596:14) at Request.transition (/var/runtime/node_modules/aws-sdk/lib/request.js:21:10) at AcceptorStateMachine.runTo (/var/runtime/node_modules/aws-sdk/lib/state_machine.js:14:12) at /var/runtime/node_modules/aws-sdk/lib/state_machine.js:26:10 at Request.<anonymous> (/var/runtime/node_modules/aws-sdk/lib/request.js:37:9) END RequestId: 15c2b976-fa62-11e5-ae3d-eb178e7400bf REPORT RequestId: 15c2b976-fa62-11e5-ae3d-eb178e7400bf Duration: 892.83 ms Billed Duration: 900 ms Memory Size: 128 MB Max Memory Used: 16 MB Process exited before completing request

Any idea?

@mwhouser
Copy link
Contributor

mwhouser commented Apr 4, 2016

  1. In our projects, we used NPM to install the markup-js project. When this is done, it's loaded by require('markup-js'). If you are downloading markup.js yourself, then you'll need to adjust the require statement. I have added a package.json file so you should be able to just npm install to get the dependencies.
  2. If you're getting an error Cannot call method 'match' of undefined, then your template is undefined when calling mark.up. Based on the logs you posted, the subject is the culprit. Since you're not setting a subject in your event, then it tries to pull the default subject from config.js. Ensure a default subject is defined:
var config = {
    "templateBucket" : "my-bucket",
    "templateKey" : "Templates/Template.html",
    "targetAddress" : "my-email@domain.com",
    "fromAddress": "Me <my-email@domain.com>",
    "defaultSubject" : "Email From {{name}}"
}

@mwhouser
Copy link
Contributor

mwhouser commented Apr 4, 2016

I have added a check to ensure we have a valid subject for the email.

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