I have a post-registration hook enabled to call an api I have set up to send email. When I run it in the runner I get the following error message. When I run it normally and watch the logs, nothing errors, but the email doesn’t send.
Error:
{ “message”: “Unable to compile the extensibility code as javascript”, “statusCode”: 500, “error_description”: “Invalid or unexpected token”, “stack”: “/data/io/758c3e0e-2f8c-4b39-a2ff-f1cd92552dbc/webtask.js:4\nmethod: ‘POST’,\n ^\n\nSyntaxError: Invalid or unexpected token\n at createScript (vm.js:80:10)\n at Object.runInThisContext (vm.js:139:10)\n at WebtaskModule.compileWebtask (/data/sandbox/lib/module.js:140:30)\n at Object.defaultJavascriptCompiler [as nodejsCompiler] (/data/sandbox/lib/compiler.js:135:24)\n at extensibilityPointCompiler (/data/sandbox/node_modules/auth0-ext-compilers/lib/compilers/compilerFactory.js:24:17)\n at /data/sandbox/lib/compiler.js:276:11\n at /data/sandbox/node_modules/async/dist/async.js:3880:24\n at replenish (/data/sandbox/node_modules/async/dist/async.js:1011:17)\n at /data/sandbox/node_modules/async/dist/async.js:1016:9\n at eachOfLimit (/data/sandbox/node_modules/async/dist/async.js:1041:24)” }
Code inside of hook:
module.exports = function(user, context, cb) {
var request = require(‘request’);
request({
method: ‘POST’,
url: ‘…/api/email’,
headers: {
‘Content-Type’: ‘application/json’,
},
body: { “emailAddress”: “${user.emailAddress}”,
“emailType”: “${user.user_metadata.nesletter}”,
“source”: “{test}”}
}, function(error, response, body) {
console.log(user)
console.log(context)
cb(error, response)
});
};