async sendMessage(message) {
const slackEndpoint = 'https://hooks.slack.com/services/........';
return await axios.post(slackEndpoint,
{text: message})
.catch((error) => console.log(error));
}
let response = await this.sendMessage(message);
this.logger.info('Sending Slack message for amount threshold: ' + message);
console.log("!!!!!!!!!!!!! ", response.statusText )
if (response.statusText == 'OK') {
this.logger.info('sent');
}
else {
this.logger.error('NOT send!');
}
I get response:
{
status: 200,
statusText: 'OK',
headers: {
date: 'Thu, 09 Dec 2021 17:29:29 GMT',
..............
}
And error:
TypeError: Cannot read properties of undefined (reading 'statusText')
Do you know how I can properly get the value of statusText and compare it?
Try this:
async sendMessage(message) {
const slackEndpoint = 'https://hooks.slack.com/services/........';
return await axios.post(slackEndpoint,
{text: message})
.then(response => response)
.catch((error) => console.log(error));
}