Serve a request

Imagine your visitor makes a request to //example.com/page and you want to respond with the text full page example.

First, create a file named page under //example.com and set its type to app-1. That turns your page file into an app.

Then, create a file named .Request inside it and set its type to sjs-4. This file is called a method file, it will be executed in the sjs-4 JavaScript engine.

Then set the body of the .Request file to response.body('full page example'); and try visiting the page in your browser - it should work.

Subscribe to our newsletter!