Send Grid Auto Responder Issues

Hi everyone and thanks in advance for any help offered

i have a form - feeds into a data base
i need an email sent to me and an auto responder email sent to the person who filled the form out

Ive followed the instructions here

i have it sending form inputs to me no problem

however when I’ve added additional code to also send out auto responder message - it stoped sending the form inputs to me. But does send out the auto responder with inputs ( to be changed to html email later)

//email.jsw

import {sendWithService} from ‘backend/sendGrid’;

export function sendEmail(subject, body) {
const key = “hidden”;
const sender = “hidden”;
const recipient = “hidden”;
return sendWithService(key, sender, recipient, subject, body);
}

export function sendEmailWithRecipient(subject, body, recipient) {
const key = “hidden”;
const sender = “hidden”;
return sendWithService(key, sender, recipient, subject, body);
}

//front end event handler

import {sendEmail, sendEmailWithRecipient} from ‘backend/email’;

$w.onReady(function () {
$w(“#dataset1”).onAfterSave(sendFormData);
});

function sendFormData() {
const subject = New Submission from ${$w("#inputName").value};
const body = Name: ${$w("#inputName").value} \rEmail: ${$w("#inputEmail").value} \rPhone: ${$w("#inputTelephone").value} \rChoice: ${$w("#InputChoice").value};
const recipient = $w(“#inputEmail”).value;

sendEmailWithRecipient(subject, body, recipient)
.then(response => console.log(response));
}

//sendGrid.js

import {fetch} from ‘wix-fetch’;

export function sendWithService(key, sender, recipient, subject, body) {
const url = “https://api.sendgrid.com/api/mail.send.json”;

const headers = {
“Authorization”: "Bearer " + key,
“Content-Type”: “application/x-www-form-urlencoded”
};

const data = from=${sender}&to=${recipient}&subject=${subject}&text=${body};

const request = {
“method”: “post”,
“headers”: headers,
“body”: data
};

return fetch(url, request)
.then(response => response.json());
}

Hi,
Can you be more specific? what code did you change from the instructions?
Roi.

Hi Roi, haven’t changed any code just re used code from article

Hi Simon,
Few questions,

  1. Did you check the spam folder in your email?
  2. Where in the code do you trigger the function on the second to send additional email (auto responder)?
  3. Can you explain how you reused the code?
  4. Please paste a link to your site in case I’ll need it for further inspection.
    Roi.