-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
In the coffee machine tutorial, there is the following code:
thing.setPropertyReadHandler('availableResourceLevel', (options) => {
// Check if uriVariables are provided
if (options && typeof options === 'object' && 'uriVariables' in options) {
const uriVariables: any = options['uriVariables'];
if ('id' in uriVariables) {
return thing.readProperty('allAvailableResources').then((resources) => {
const id = uriVariables['id'];
return new Promise((resolve, reject) => {
resolve(resources[id]);
});
});
}
}
return new Promise((resolve, reject) => {
resolve('Please specify id variable as uriVariables.');
});
});The first part is completely fine but the last lines on returning a Promise will actually make the Client think that everything is OK since in HTTP it would map to 200 status code. The correct way would be to return an HTTP 400 Bad Request but this is not possible at the moment (See this issue on node-wot: eclipse-thingweb/node-wot#140). For now, this should at least be a reject instead of a resolve.
Could you correct this @fatadel ?
Metadata
Metadata
Assignees
Labels
No labels