рдЗрд╕реЗ рд▓реИрдореНрдмреНрдбрд╛ рдХреЗ рд▓рд┐рдП рдиреЗрдЯрд▓рд┐рдлрд╛рдИ рдлрд╝рдВрдХреНрд╢рди рд╣реИрдВрдбрд▓рд░ рдореЗрдВ рдбрд╛рд▓рдирд╛
// For more info, check https://www.netlify.com/docs/functions/#javascript-lambda-functions
export function handler(event, context, callback) {
console.log('sending')
console.log(event)
console.log(context)
const sgMail = require('@sendgrid/mail')
sgMail.setApiKey(process.env.SENDGRID_API_KEY)
const msg = {
to: '[email protected]',
from: '[email protected]',
templateId: '#ID',
dynamic_template_data: {
recipient: 'alex',
},
}
sgMail.send(msg).catch(function(error) {
console.log(error)
})
console.log('sent sign up')
}
рдореБрдЭреЗ рдирд┐рдореНрдирд▓рд┐рдЦрд┐рдд рдорд┐рд▓рддрд╛ рд╣реИ:
TypeError: s is not a function
at e.exports.deepMergeDynamicTemplateData (/Users/amlcodes/Documents/projects/cctmvp/lambda/mailinglist.js:127:27164)
at p.applyDynamicTemplateData (/Users/amlcodes/Documents/projects/cctmvp/lambda/mailinglist.js:211:117545)
at p.addPersonalization (/Users/amlcodes/Documents/projects/cctmvp/lambda/mailinglist.js:211:116796)
at p.addTo (/Users/amlcodes/Documents/projects/cctmvp/lambda/mailinglist.js:211:116994)
at p.fromData (/Users/amlcodes/Documents/projects/cctmvp/lambda/mailinglist.js:211:115579)
at new p (/Users/amlcodes/Documents/projects/cctmvp/lambda/mailinglist.js:211:114482)
at Function.create (/Users/amlcodes/Documents/projects/cctmvp/lambda/mailinglist.js:211:120622)
at e.exports.send (/Users/amlcodes/Documents/projects/cctmvp/lambda/mailinglist.js:1:156753)
at Object.a.handler (/Users/amlcodes/Documents/projects/cctmvp/lambda/mailinglist.js:127:36900)
at /Users/amlcodes/Documents/projects/cctmvp/node_modules/netlify-lambda/lib/serve.js:79:27
at Layer.handle [as handle_request] (/Users/amlcodes/Documents/projects/cctmvp/node_modules/express/lib/router/layer.js:95:5)
at next (/Users/amlcodes/Documents/projects/cctmvp/node_modules/express/lib/router/route.js:137:13)
at next (/Users/amlcodes/Documents/projects/cctmvp/node_modules/express/lib/router/route.js:131:14)
at next (/Users/amlcodes/Documents/projects/cctmvp/node_modules/express/lib/router/route.js:131:14)
at next (/Users/amlcodes/Documents/projects/cctmvp/node_modules/express/lib/router/route.js:131:14)
at next (/Users/amlcodes/Documents/projects/cctmvp/node_modules/express/lib/router/route.js:131:14)
[HPM] Error occurred while trying to proxy request mailinglist from localhost:8000 to http://localhost:9000 (ECONNRESET) (https://nodejs.org/api/errors.html#errors_common_system_errors)
рдЗрд╕ рдХреЙрд▓ рдХреЗ рд╕рд╛рде
fetch('/.netlify/functions/mailinglist', {
method: 'POST',
body: JSON.stringify({
// recipient: this.state.recipient,
recipient: 'alex',
}),
headers: new Headers({
'Content-Type': 'application/json',
}),
})
.then(res => {
console.log('Signup processed successfully')
this.setState({ signupmessage: 'Signup Successful!' })
return res
})
.catch(error => {
console.error('Error:', error)
this.setState({ signupmessage: 'Signup Failed' })
})
рдЬрдирд░реЗрдЯ рдХреА рдЧрдИ mailinglist.js рдореЗрдВ this.dynamicTemplateData=s(e,this.dynamicTemplateData)}}
рд╣реИрд▓реЛ @amlcodes ,
рдРрд╕рд╛ рд▓рдЧрддрд╛ рд╣реИ рдХрд┐ Netlify рдиреЗ рдЗрд╕ рдХреЛрдб рдХреЛ рдЬреЛрдбрд╝рд╛ рд╣реИ s(e,this.dynamicTemplateData)
рдкрд░рд┐рднрд╛рд╖рд┐рдд рдХрд┐рдП рдмрд┐рдирд╛ рдХрд┐ рдлрд╝рдВрдХреНрд╢рди s
рд╣реИред рдХреНрдпрд╛ рд╣реЛрддрд╛ рд╣реИ рдЬрдм рдЖрдк рдЙрд╕ рд▓рд╛рдЗрди рдХреЛ рд╣рдЯрд╛ рджреЗрддреЗ рд╣реИрдВ?
рд╢реБрднрдХрд╛рдордирд╛рдПрдВ,
рдПрд▓реНрдореЗрд░реВ
рдореБрдЭреЗ рднреА рдпрд╣реА рд╕рдорд╕реНрдпрд╛ рд╣реИред
рдпрд╣ рдХреЗрд╡рд▓ рддрдм рд╣реЛрддрд╛ рд╣реИ рдЬрдм рдореИрдВ templateId
рдЙрдкрдпреЛрдЧ рдХрд░рддрд╛ рд╣реВрдВ, рдХреЗрд╡рд▓ Netlify рдкрд░ (рдпрд╣ рдореЗрд░реА рд╕реНрдерд╛рдиреАрдп рдорд╢реАрди, рдиреЛрдб 10.16.0) рдкрд░ рдмрд┐рдирд╛ рдХрд┐рд╕реА рд╕рдорд╕реНрдпрд╛ рдХреЗ рдХрд╛рдо рдХрд░рддрд╛ рд╣реИред
рдореБрдЭреЗ рдирд╣реАрдВ рдкрддрд╛ рдХрд┐ рдЙрд╕ рд▓рд╛рдЗрди рдХреЛ рдХреИрд╕реЗ рд╣рдЯрд╛рдпрд╛ рдЬрд╛рдП рдФрд░ рдкрд░рд┐рдгрд╛рдо рджреЗрдЦреЗрдВ, рд╕рдорд╕реНрдпрд╛ рдХреЗрд╡рд▓ Netlify рдкрд░ рд╣реИред
рдХреНрдпрд╛ рдЖрдк рдпрд╣ рджреЗрдЦрдиреЗ рдХреЗ рд▓рд┐рдП рдорд┐рдирд┐рдлрд┐рдХреЗрд╢рди рдХреЛ рдмрдВрдж рдХрд░рдиреЗ рдХрд╛ рдкреНрд░рдпрд╛рд╕ рдХрд░ рд╕рдХрддреЗ рд╣реИрдВ рдХрд┐ рдЕрдВрддрд░реНрдирд┐рд╣рд┐рдд рд╕рдорд╕реНрдпрд╛ рдХреНрдпрд╛ рд╣реИ? https://github.com/netlify/netlify-lambda#debugging
рд╡рд╛рд╕реНрддрд╡ рдореЗрдВ, рдпрд╣ рдирд┐рд╢реНрдЪрд┐рдд рд░реВрдк рд╕реЗ https://github.com/sendgrid/sendgrid-nodejs/pull/1039 рджреНрд╡рд╛рд░рд╛ рддрдп рдХрд┐рдпрд╛ рдЬрд╛рдПрдЧрд╛ред