29 lines
1013 B
JavaScript
29 lines
1013 B
JavaScript
// JavaScript Document
|
|
// V1.0.0
|
|
|
|
exports.onesignal_delete_notification = async function (options) {
|
|
|
|
const appid = this.parseOptional(options.appid, '*', process.env.ONESIGNAL_APP_ID)
|
|
console.log(options.appid + " => " + appid)
|
|
|
|
const notificationid = this.parseRequired(options.notificationid, '*', 'No notification ID specified')
|
|
console.log(options.notificationid + " => " + notificationid)
|
|
|
|
const fetch = require('node-fetch');
|
|
|
|
const url = `https://api.onesignal.com/notifications/${notificationid}?app_id=${appid}`
|
|
console.log(url)
|
|
const os_options = {
|
|
method: 'DELETE',
|
|
headers: { accept: 'application/json', Authorization: `Basic ${process.env.ONESIGNAL_REST_API_KEY}` }
|
|
};
|
|
console.log(os_options)
|
|
return fetch(url, os_options)
|
|
.then(res => {
|
|
return res.json().then(json => {
|
|
json.status = res.status; // Add status to json response
|
|
return json;
|
|
});
|
|
})
|
|
.catch(err => console.error('Error:', err));
|
|
} |