uptime-kuma/server/notification-providers/postrequest.js

34 lines
883 B
JavaScript
Raw Normal View History

2024-11-10 13:52:26 +01:00
const NotificationProvider = require("./notification-provider");
const axios = require("axios");
class PostRequest extends NotificationProvider {
name = "PostRequest";
2024-11-10 14:06:35 +01:00
/**
* @inheritdoc
*/
2024-11-10 13:52:26 +01:00
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
const okMsg = "Sent Successfully.";
const url = notification.postrequestURL;
try {
2024-11-10 14:06:35 +01:00
let config = {
2024-11-10 13:52:26 +01:00
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer " + notification.postrequestToken,
}
};
let data = notification.postrequestBody;
let resp = await axios.post(url, data, config);
return okMsg;
} catch (error) {
this.throwGeneralAxiosError(error);
}
}
}
module.exports = PostRequest;