Skip to content

Commit

Permalink
improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
CFenner committed Jan 4, 2024
1 parent f9cf91b commit 79b8ffe
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,21 @@ module.exports = {
},
loadData: async function (payload) {
const self = this
self.config = payload.config
const identifier = payload.identifier
const url = `https://${self.config.apiBase}${self.config.dataEndpoint}${self.config.location}/?token=${this.config.token}`
console.log(`AirQuality loaded: ${url}`)
const url = `https://${payload.config.apiBase}${payload.config.dataEndpoint}${payload.config.location}/?token=${payload.config.token}`
console.log(`AirQuality-Fetcher: ${url}`)

const result = await fetch(url)
.then(response => response.json())

self.sendSocketNotification(self.notifications.DATA_RESPONSE, {
payloadReturn: { identifier, result },
payloadReturn: { identifier: payload.identifier, result },
status: 'OK',
})
},
socketNotificationReceived: function (notification, payload) {
switch (notification) {
case this.notifications.DATA:
console.log(`AirQuality-Fetcher: Loading data of ${payload.config.location} for module ${payload.identifier}`)
this.loadData(payload)
break
}
Expand Down

0 comments on commit 79b8ffe

Please sign in to comment.