// JavaScript Document
// V1.0.0 complete

// note uses auth key, not api key
// no status returned! need to double check schema

exports.onesignal_getapps = async function (options) {

   const fetch = require('node-fetch');

   const url = 'https://api.onesignal.com/apps';
   const os_options = {
      method: 'GET',
      headers: {
         accept: 'text/plain',
         Authorization: `Basic ${process.env.ONESIGNAL_AUTH_KEY}`
      }
   };
   console.log(url)
   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));
}