const options = {
2 method: 'POST',
3 headers: {
4 Accept: 'application/json',
5 Authorization: 'Basic YOUR_REST_API_KEY',
6 'Content-Type': 'application/json'
7 },
8 body: JSON.stringify({
9 included_segments: ['Subscribed Users'],
10 contents: {en: 'English or Any Language Message', es: 'Spanish Message'},
11 name: 'INTERNAL_CAMPAIGN_NAME'
12 })
13};
14
15fetch('https://onesignal.com/api/v1/notifications', options)
16 .then(response => response.json())
17 .then(response => console.log(response))
18 .catch(err => console.error(err));