add error message for missing api key

This commit is contained in:
peter
2022-07-16 21:12:25 +00:00
parent db219f3168
commit 7fbd0de9b5

View File

@@ -34,19 +34,23 @@ instance.prototype.init = function () {
self.init_presets() self.init_presets()
self.auth() self.auth()
self.getWorkspace() self.getWorkspace()
self.getCurrentTimer().then((result) => { self.getCurrentTimer().then((timerId) => {
self.log('debug', 'Current timer id ' + result) self.log('debug', 'Current timer id ' + timerId)
}) })
self.actions() self.actions()
} }
instance.prototype.auth = function () { instance.prototype.auth = function () {
var self = this var self = this
auth = Buffer.from(self.config.apiToken + ':' + 'api_token').toString('base64')
self.header = [] self.header = []
self.header['Content-Type'] = 'application/json'
self.header['Authorization'] = 'Basic ' + auth if (self.config.apiToken !== null && self.config.apiToken.length > 0) {
auth = Buffer.from(self.config.apiToken + ':' + 'api_token').toString('base64')
self.header['Content-Type'] = 'application/json'
self.header['Authorization'] = 'Basic ' + auth
} else {
self.log('warn', 'Please enter your toggl API token')
}
// console.log(self.header) // console.log(self.header)
} }