Skip to content

Commit 4c630a4

Browse files
docs: fix examples for CoAP and HTTP w.r.t servient.start()
1 parent 7009aad commit 4c630a4

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

packages/examples/src/bindings/coap/example-client.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ import { CoapClientFactory } from "@node-wot/binding-coap";
2020
const servient = new Servient();
2121
servient.addClientFactory(new CoapClientFactory());
2222

23-
WoT.requestThingDescription("coap://plugfest.thingweb.io:5683/testthing")
24-
.then(async (td) => {
23+
servient
24+
.start()
25+
.then(async (WoT) => {
2526
try {
26-
const WoT = await servient.start();
27+
const td = await WoT.requestThingDescription("coap://plugfest.thingweb.io:5683/testthing");
2728
const thing = await WoT.consume(td);
2829

2930
// read property
@@ -34,5 +35,5 @@ WoT.requestThingDescription("coap://plugfest.thingweb.io:5683/testthing")
3435
}
3536
})
3637
.catch((err) => {
37-
console.error("Fetch error:", err);
38+
console.error("Start error:", err);
3839
});

packages/examples/src/bindings/http/example-client.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ import { HttpClientFactory } from "@node-wot/binding-http";
2020
const servient = new Servient();
2121
servient.addClientFactory(new HttpClientFactory());
2222

23-
WoT.requestThingDescription("http://plugfest.thingweb.io:8083/testthing")
24-
.then(async (td) => {
23+
servient
24+
.start()
25+
.then(async (WoT) => {
2526
try {
26-
const WoT = await servient.start();
27+
const td = await WoT.requestThingDescription("http://plugfest.thingweb.io:8083/testthing");
2728
const thing = await WoT.consume(td);
2829

2930
// read property
@@ -34,5 +35,5 @@ WoT.requestThingDescription("http://plugfest.thingweb.io:8083/testthing")
3435
}
3536
})
3637
.catch((err) => {
37-
console.error("Fetch error:", err);
38+
console.error("Start error:", err);
3839
});

0 commit comments

Comments
 (0)