cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

How to get the result type of a javascript service ?

seanccc
17-Peridot

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 

1 ACCEPTED SOLUTION

Accepted Solutions
nmilleson
17-Peridot
(To:seanccc)

@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 */
});

 

View solution in original post

3 REPLIES 3
Jimwang
15-Moonstone
(To:seanccc)

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.

nmilleson
17-Peridot
(To:seanccc)

@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 */
});

 

slangley
23-Emerald II
(To:seanccc)

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

Top Tags