No Results
Using Custom JavaScript in the Request of Web Data Feed

JavaScript and moment.js library are available to the request body field if custom expressions are used. As a result, administrators are able to use custom JavaScript code which will be evaluated in feed runtime, perform calculations, get date and transform it, or do anything JavaScript can do.

Example:

We have created a Web data connection and a Custom feed off of it. We need to use the current timestamp in the POST request body and query the date for endDate = Date.now() and startDate = Date.now() – 24h.

To do this, we are going to click the expression icon (>_) and enter the following in the request body:

{"startDate":"{js:time.now().subtract(1, "days").format()}","endDate":"{js:time.now().format()}"} 

We already had some parameters in the request, and after adding startDate and endDate, this is what the request looks like:

{"comments": "", "customermail": "johndoe@mail.com", "customername": "johndoe", "customerphone": "6926272626", "startDate":"{js:time.now().subtract(1, "days").format()}","endDate":"{js:time.now().format()}"}


Terms | Privacy