I am trying to wrap my head around this. I just started learning javascript. Basically on my site, I have a plugin/script that asks the user a bunch of questions and at the end, it asks for their email address. I am using emailjs to send the info (well that’s what I am trying to do) but can’t figure out the proper javascript code.
In the code, if I put my email address in the variable templateParams under to_name: The email gets sent when the user enters their email and I receive it but it’s blank with no data. I don’t know how to grab the data with the info below from the plugin documentation.
onSendEmail: function(emailData) {
// User clicked send button on share by email. You have to manage sending
// the email yourself with the following data received in the parameter:
console.log(emailData);
/*
{
"data": {
"cvData": [
{
"name": "overall",
"value": 71,
"feedback": "Excellent"
},
{
"name": "smoothness",
"value": 52,
"tip": "Smoothness can be affected by using correct products.",
"info": "Healthy skin is free of dryness, hyperpigmentation, ...",
"feedback": "Good"
},
{
"name": "radiance",
"value": 73,
"info": "Skin radiance is the glowy, vibrant look we ...",
"feedback": "Excellent"
},
...
],
"products": {
"morning": {
"highend": [{product1},{product2},{product3}],
"economy": [{product4}, {product5}, {product6}],
"standard": [{product7}, {product8}, {product9}]
},
"evening": {
"highend": [{product1},{product2},{product3}],
"economy": [{product4}, {product5}, {product6}],
"standard": [{product7}, {product8}, {product9}]
}
},
"activeRoutine": "evening",
"activePriceGroup": "standard",
"activeFilters": {
"skin_type": { "value": "normal" },
"gender_ui": { "value": "female" },
"age_ui": { "value": 31 },
"eyebags_ui": { "value": 1 },
"dull_tired_ui": { "value": 1 },
"redness_ui": { "value": 1 },
"lat": { "value": 39.47504 },
"lon": { "value": -0.4117344 },
"darkspots_ui": { "value": 1 },
"wrinkles_ui": { "value": 1 }
},
"activeSelections": {
"userAllowsCamera": true,
"locationData": {
"status": "done",
"location": {
"lat": 39.47504, "lon": -0.4117344,
"city": "Valencia", "country": "Spain", "area": "Valencia",
"uvIndex": 9, "pollution": 30, "humidity": 77
}
},
"skin_type": "normal",
"skin_concerns": ["dull_tired", "redness"],
"eyebags": 1,
"darkspots": 1,
"wrinkles": 1,
"gender": "female",
"age": "31",
"selfieSource": "video"
},
},
"email": "[email protected]",
"locale": "en",
"partnerId": "XXXXXXX",
...
}
*/
let templateParams = {
to_name: 'email',
from_name: 'abc',
message: 'random message'
};
emailjs.send('SERVICE_ID', 'TEMPLATE_ID', templateParams)
.then(function(response) {
console.log('SUCCESS!', response.status, response.text);
}, function(error) {
console.log('FAILED...', error);
});
},
};