Skip to content

Commit

Permalink
Update platform.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
donavanbecker committed Oct 24, 2024
1 parent f81564d commit eec6627
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,21 @@ export class ResideoPlatform implements DynamicPlatformPlugin {

public async discoverlocations(): Promise<location[]> {
this.debugLog(`accessToken: ${this.config.credentials?.accessToken}, consumerKey: ${this.config.credentials?.consumerKey}`)
const { body } = await request(LocationURL, {
const { body, statusCode } = await request(LocationURL, {
method: 'GET',
headers: {
'Authorization': `Bearer ${this.config.credentials?.accessToken}`,
'Content-Type': 'application/json',
'apikey': this.config.credentials?.consumerKey,
},
})

this.debugLog(`Response status code: ${statusCode}`)

if (statusCode !== 200) {
throw new Error(`Failed to fetch locations: ${statusCode}`)
}

const locations = await body.json() as location[]
this.debugLog(`(discoverlocations) Location: ${JSON.stringify(locations)}`)
return locations // Ensure this returns an array
Expand Down

0 comments on commit eec6627

Please sign in to comment.