Helo! I have a small problem with this interface:
interface Template {
from_name: string;
to_name: string;
fullName: string;
company: string;
email: string;
msg: string;
}
and I will use this here:
const onSubmit: SubmitHandler<IFormInput> = (data) => {
let serviceId: any = process.env.REACT_APP_SERVICE_ID;
let templateId: any = process.env.REACT_APP_TEMPLATE_ID;
let userID: any = process.env.REACT_APP_USER_ID;
let templateParams: Template = {
from_name: "Contact Mailer",
to_name: `${process.env.REACT_APP_TO_EMAIL}`,
fullName: `${data.fullName}`,
company: `${data.company}`,
email: `${data.email}`,
msg: `${data.message}`,
};
emailjs
.send(`${serviceId}`, `${templateId}`, templateParams, `${userID}`)
.then(
function (response) {
response.status ? setOpenSucces(true) : setOpenFail(true);
},
function (error) {
setOpenFail(true);
console.log("FAILED...", error);
}
)
.catch((err) => {
setOpenFail(true);
console.log(err);
});
};
Returns me an error:
Unable to assign an argument of type "Template" to a parameter of type "Record<string, unknown>". No index signature for type "string" in type "Template".ts(2345)
What am I doing wrong?