The quickest way to "test out" a PJS module to see how things work is to create it as a Express Route (web service), and call it using a browser.
Example 1
In the following example, we'll create a web service to pass in a customer number = 1234, and get back the customer nameĀ for that customer number.
...
- Now, you can "call" that PJS module as a web service from a browser, using the URL http://localhost:8081/run/pjstips/pjstips_02_1 . The format of the URL is http://host:port/run/<Route Path>, where <Route Path> is as shown in the picture above.
- If you want to pass parameters to the PJS module from the browser, you can use query string parameters, in the format of :
- <yourURL>?parm1=value1&parm2=value2
- For example, use this URLĀ http://localhost:8081/run/pjstips/pjstips_02_1?custno=1234 to pass a parm of "custno" with value of "1234" to the PJS module.
- To debug the module pjstips_02_1.js, put itin debug using your favorite debug tool (e.g. VS Code or Chrome), add a breakpoint, then call it from a browser.
Example 2
The previous example sends back the "response" as a text message. In the next example, we'll send back the reponse as JSON.
...