Emmz
Posts: 0
Joined: Sat Jun 23, 2012 11:06 pm

Run Restservice with dynamic name

Hey gang..

I have a rest service defined in Tiggzi named. "test1"

I need to Invoke this Service using JS.
test1.execute({});
This is fine.
But I want to have the name of service to execute dynamic.
I tried..
var myservice = "test1";
myservice.execute({})
But get error TypeError: Object Service1 has no method 'execute'

Can U help?
Tks

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Run Restservice with dynamic name

No, that will not work because 'myservice' is a string in your code. It's possible to do that.. but a lot more involved. Export the source and see how we do it when you define a sample service.

Emmz
Posts: 0
Joined: Sat Jun 23, 2012 11:06 pm

Run Restservice with dynamic name

I see...
execute: function(settings) {
settings = this.__buildRequestSettings(settings);
this.service.process(settings);
},
Working with this is way over my head.. lol

I will just send the service name with the data as array on a call function.
Split to get service name then check for name match then use the static myservice.execute({})

Thanks again Max...

Emmz
Posts: 0
Joined: Sat Jun 23, 2012 11:06 pm

Run Restservice with dynamic name

Went with the dreaded eval().....
Made array. Put myservice.execute({}); as item 0.
Called my Function that processes all My Rest Services.
Saves to LocalStorage.
Split out item[0]
string = theArray[0];
eval(string);

Works GREAT ..

Return to “Issues”