Skip to main content
17-Peridot
Dec 13, 2020 2:30 AM UTC
Solved

How to get the result type of a javascript service ?

Hi, 

I have dynamic JavaScript service , like :   let result =  Things[thingName][serviceName](serviceParam); 

 

How can I get the base type of the result for such a dynamic service ? 

 

Regards,

Sean 

nmillesonAnswer
17-Peridot
Dec 14, 2020 6:34 PM UTC

@seanccc ,

 

You can use the GetServiceDefinition() service on a Thing and it will tell you the return type.  Hope that helps.

var result = Things["myThing"].GetServiceDefinition({
	name: "myService" /* STRING */
});

 

3 replies

16-Pearl
Dec 14, 2020 7:09 AM UTC

The return result type is based on the service what you are calling. Different service will return different object type. You need to check the return type of the exact service.

Translate
nmilleson17-PeridotAnswer
17-Peridot
Dec 14, 2020 6:34 PM UTC

@seanccc ,

 

You can use the GetServiceDefinition() service on a Thing and it will tell you the return type.  Hope that helps.

var result = Things["myThing"].GetServiceDefinition({
	name: "myService" /* STRING */
});

 

Translate
Support
Dec 22, 2020 6:34 PM UTC

Hi @seanccc.

 

If your question has been answered, please mark the appropriate response as the Accepted Solution for the benefit of others with the same question.

 

Regards.

 

--Sharon

Translate