Ilya
Posts: 0
Joined: Tue Dec 17, 2013 7:02 pm

custom js logic on service response

what is the api for service response? e.g. i want with moment js display date in particular format. i add custom js code to response - "moment().format('dddd');" but it doesn't work

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

custom js logic on service response

Where exactly did you add the JavaScript?

Ilya
Posts: 0
Joined: Tue Dec 17, 2013 7:02 pm

custom js logic on service response

page - data - service - response - component (text field) (add js)

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

custom js logic on service response

Test to make sure the script you are using works outside of mapping.. just by running it. Use the same data type/format that you get from the service.

Ilya
Posts: 0
Joined: Tue Dec 17, 2013 7:02 pm

custom js logic on service response

Hi Max. It works fine. You can check this here: http://appery.io/app/mobile-frame?src...
Please click on 'Заполнить время из перем..."

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

custom js logic on service response

It works standalone and in mapping or only in standalone example?

Ilya
Posts: 0
Joined: Tue Dec 17, 2013 7:02 pm

custom js logic on service response

Max, only in standalone mode. In mapping it doesn't work

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

custom js logic on service response

Hi Ilya,

For mapping you should use the following JS: prereturn moment(value).format("dddd, MMMM Do YYYY, h:mm:ss a");/pre
Then a processed value will be returned to a mapped element.

Ilya
Posts: 0
Joined: Tue Dec 17, 2013 7:02 pm

custom js logic on service response

Katya, thank you.
This worked for me.
Could you please explain the logic of the JS you provided.
E.g. the service provided response, then to whom it is 'return'ed? To the page? And then what is 'value'? It's value of response of service? Why is it called 'value'?

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

custom js logic on service response

What code did you have before?

This explains what is 'value': http://docs.appery.io/documentation/r...

Return to “Issues”