Skip to content

Bug in API javascript-example-code sample #494

Description

@manni-2x

Analysis

There is a bug in API javascript-example-code. Body parameter is not included in http POST call. Therefore the sample will never working.

Moreover, relays are not working, despite of this success response is given anyway.

Expected Behavior

javascript-example-code is working.
For it an body parameter has to be included in http POST call:
const options = {
hostname: 'api.switch-bot.com',
port: 443,
path: /v1.1/devices/${deviceId}/commands,
method: 'POST',
body: body, // has to be included
headers: {
"Authorization": token,
"sign": sign,
"nonce": nonce,
"t": t,
'Content-Type': 'application/json',
'Content-Length': body.length,
},
};

Steps To Reproduce

Use javascript-example-code and check relays workinng (success response is given anyway)

Logs

n.a.

Configuration

n.a.

Environment

Plattform: docker (official image - v11.1.0)
Betriebssystem: linux
Architektur: arm64
CPUs: 4
Geschwindigkeit: 1800 MHz
Modell: Cortex-A72
RAM: 3.7 GB
System-Betriebszeit: 3 T. 23:08:45
Node.js: v22.22.2
Zeit: 6.7.2026, 15:54:14
Zeitversatz: -120
NPM: 10.9.7

Additional Context

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions