英文:
the table in html is rendering a comma without any reason
问题
I have translated the code portion for you:
const mailOptions = {
from: "xyz@gmail.com",
to: "yzx@gmail.com",
subject: "Issue Persisting for a long time",
html:
"<h2>These are the issues persisting for a long time</h2><ul> " +
`<table style="border: 1px solid black;">
<thead>
<tr>
<th style="border: 1px solid black;">description</th>
<th style="border: 1px solid black;">department</th>
<th style="border: 1px solid black;">Location</th>
<th style="border: 1px solid black;">Date</th>
</tr>
</thead>
<tbody>
${data.map((item) => {
return `
<tr>
<td>sdfsdf</td>
<td>sdfsdf</td>
<td>sdfsdf</td>
<td>sdfsdf</td>
</tr>`
})}
</tbody>
</table>`,
};
transporter.sendMail(mailOptions, (error, info) => {
if (error) {
res.send(error);
} else {
console.log(mailOptions.text);
res.send("Email sent: " + info.response);
}
});
If you have any other code sections to translate or need further assistance, please let me know.
英文:
the table in html is rendering a comma without any reason i am using nodemailer and smtp google server i feel it is something with respect to the html but i am not able to figure out
const mailOptions = {
from: "xyz@gmail.com",
to: "yzx@gmail.com",
subject: "Issue Persisting for long time",
html:
"<h2>These are the issues persisting for long time</h2><ul> " +
`<table style="border: 1px solid black;" >
<thead>
<tr>
<th style="border: 1px solid black;">description</th>
<th style="border: 1px solid black;">department</th>
<th style="border: 1px solid black;">Location</th>
<th style="border: 1px solid black;">Date</th>
</tr>
</thead>
<tbody>
${data.map((item) => {
return `
<tr>
<td>sdfsdf</td>
<td>sdfsdf</td>
<td>sdfsdf</td>
<td>sdfsdf</td>
</tr>`
})}
</tbody>
</table>`,
};
transporter.sendMail(mailOptions, (error, info) => {
if (error) {
res.send(error);
} else {
console.log(mailOptions.text);
res.send("Email sent: " + info.response);
}
});
答案1
得分: 3
Your map
invocation returns an array here:
<tbody>
${data.map((item) => {
return `
<tr>
<td>sdfsdf</td>
<td>sdfsdf</td>
<td>sdfsdf</td>
<td>sdfsdf</td>
</tr>`
})}
</tbody>
The default string representation of an array is the comma-separated representation of each of its elements.
You can fix it by stringifying the array yourself, e.g. change the .map(..)
to .map(..).join("")
.
英文:
Your map
invocation returns an array here:
<tbody>
${data.map((item) => {
return `
<tr>
<td>sdfsdf</td>
<td>sdfsdf</td>
<td>sdfsdf</td>
<td>sdfsdf</td>
</tr>`
})}
</tbody>
The default string representation of an array is the comma-separated representation of each of its elements.
You can fix it by stringifying the array yourself, e.g. change the .map(..)
to .map(..).join("")
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论