Skip to main content

Hello World Example

The simplest Invoke function examples.

Basic Hello World

module.exports = function(req, res) {
res.json({
message: 'Hello World!',
timestamp: new Date().toISOString()
});
};

Test:

curl http://<your invoke-execution URL>/invoke/{functionId}

Response:

{
"message": "Hello World!",
"timestamp": "2026-02-10T12:00:00.000Z"
}

With Query Parameters

module.exports = function(req, res) {
const name = req.query.name || 'World';
const greeting = req.query.greeting || 'Hello';

res.json({
message: `${greeting}, ${name}!`,
timestamp: new Date().toISOString()
});
};

Test:

curl "http://<your invoke-execution URL>/invoke/{functionId}?name=Alice&greeting=Hi"

Response:

{
"message": "Hi, Alice!",
"timestamp": "2026-02-10T12:00:00.000Z"
}

Async Hello World

module.exports = async function(req, res) {
// Simulate async operation
await sleep(100);

res.json({
message: 'Hello from async function!',
timestamp: new Date().toISOString()
});
};

Request Information

module.exports = function(req, res) {
res.json({
message: 'Hello World!',
request: {
method: req.method,
path: req.path,
query: req.query,
headers: {
userAgent: req.get('user-agent'),
host: req.get('host')
}
},
timestamp: new Date().toISOString()
});
};

Different Response Formats

JSON

module.exports = function(req, res) {
res.json({ message: 'Hello World!' });
};

Plain Text

module.exports = function(req, res) {
res.send('Hello World!');
};

HTML

module.exports = function(req, res) {
res.type('html').send(`
<!DOCTYPE html>
<html>
<head><title>Hello</title></head>
<body>
<h1>Hello World!</h1>
<p>Timestamp: ${new Date().toISOString()}</p>
</body>
</html>
`);
};

Next Steps