Skip to content

setProperty result scoping #9

@jakefishbain

Description

@jakefishbain

it looks as though storing result as a const on line 224 does so within the scope of the try/catch instead of the variable initially instantiated on 212. Removing const and modifying the line to be

result = await axios.post(`${this.baseUrl}/app/v2/device/set_property`, await this.getRequestBodyData(data))

seems to fix the issue.

wyze-node/index.js

Lines 211 to 231 in c16d427

async setProperty(deviceMac, deviceModel, propertyId, propertyValue) {
let result
try {
await this.getTokens();
if (!this.accessToken) {
await this.login()
}
const data = {
device_mac: deviceMac,
device_model: deviceModel,
pid: propertyId,
pvalue: propertyValue,
}
const result = await axios.post(`${this.baseUrl}/app/v2/device/set_property`, await this.getRequestBodyData(data))
} catch (e) {
console.log('Error...', e)
throw e
}
return result.data
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions