J'ai écrit une API pour envoyer un email. J'utilise Postman pour ça. Cela fonctionne bien avec du texte normal. Lorsque vous ajoutez la balise de script dans le "HTML", l'erreur suivante est générée.Tags Javascript ne fonctionne pas en HTML
400 Bad Request
avec le corps de réponse
SyntaxError: Unexpected token
at Object.parse (native)
at parse (/root/node_modules/body-parser/lib/types/json.js:88:17)
at /root/node_modules/body-parser/lib/read.js:116:18
at invokeCallback (/root/node_modules/body-parser/node_modules/raw-body/index.js:262:16)
at done (/root/node_modules/body-parser/node_modules/raw-body/index.js:251:7)
at IncomingMessage.onEnd (/root/node_modules/body-parser/node_modules/raw-body/index.js:307:7)
at IncomingMessage.EventEmitter.emit (events.js:92:17)
at _stream_readable.js:920:16
at process._tickDomainCallback (node.js:459:13)
Le corps de la demande J'adresse est la suivante: Basé sur
{
"from": "\"David Johnson\" <[email protected]>",
"to": "[email protected]",
"subject": "Test",
"html": "Dear David, <br /> <br /> Thanks for the mail. PFB the detailed report.
<script src=\"https://code.highcharts.com/highcharts.js\"></script>
<script src=\"https://code.highcharts.com/modules/exporting.js\"></script>
<div id=\"container\" style=\"min-width: 310px; height: 400px; margin: 0 auto\"></div>
<script>
Highcharts.chart('container',
{
chart: {
type: 'areaspline'
},
title: {
text: 'Bandwidth Utilization'
},
legend: {
layout: 'vertical',
align: 'left',
verticalAlign: 'top',
x: 150,
y: 100,
floating: true,
borderWidth: 1,
backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'
},
xAxis: {
categories: [
'00: 00',
'01: 00',
'02: 00',
'03: 00',
'04: 00',
'05: 00',
'06: 00',
'07: 00',
'08: 00',
'09: 00',
'10: 00',
'11: 00',
'12: 00',
'13: 00',
'14: 00',
'15: 00',
'16: 00',
'17: 00',
'18: 00',
'19: 00',
'20: 00',
'21: 00',
'22: 00',
'23: 00'
],
title: {
text: 'Hours (GMT)'
}
},
yAxis: {
title: {
text: 'Bandwidth (Mbps)'
}
},
tooltip: {
shared: true,
valueSuffix: ' Mbps'
},
credits: {
enabled: false
},
plotOptions: {
areaspline: {
fillOpacity: 0.5
}
},
series: [
{
name: 'India - (GMT +5.5)',
data: [
3,
5,
4,
10,
12,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
3,
4,
3
]
},
{
name: 'Ireland - (GMT +0.0)',
data: [
1,
3,
4,
3,
3,
5,
4,
4,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
},
{
name: 'Samoa - (GMT -11.0)',
data: [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
3,
4,
4,
9,
15,
10,
12,
0,
0,
0,
0
]
}
]
});
</script>"
}
Merci, @Roman pour la réponse. Cela fonctionne bien. :) –