REST Resource adding Javascript

(Nick Papadatos) #1

Matrix Version: 5.5.4

Hi Squiz folk, I have a rest asset and I’m trying to add the following of code.

This is ok
print('<script src=""></script>');

But how do I add the following script to the rest asset?

        var dateMonthAsWord = moment("2019-12-23").format('DD MM YY');

I’m trying to control the date format in the display output to 23 12 2019


(Byrne) #2

So you can:

  • nest the REST asset in a page and include that Script that calls moment after it.
  • process the date change directly on the data returned in the REST response server side.

processing everything server side is a faster way to process the page.

(Nick Papadatos) #3

Too easy, thanks Andrew