Slack webhook & unicode?

How to send a message to a slack webhook in sending via curl -X POST -H 'Content-type: application/json' messages arrive when sent from node get invalid_payload

function sendMessage(path, text) {
let postData = JSON.stringify({
'text': text
});
let options = {
hostname: 'hooks.slack.com',
path: path,
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': postData.length
}
};
let req = https.request(options, (response) => {
let str = ";
response.on('data', (chunk) => {
str += chunk;
});

response.on('end', () => {
console.log('Slack send');
console.log(str)
})
});
req.on('error', (e) => {
console.log(`problem with request: ${e.message}`);
});
req.write(postData);
req.end();
}
July 9th 19 at 10:05
0 answer

Find more questions by tags JavaScriptNode.js