Edit your function

This page will walk you through editing a Binaris function.

If you are new to Binaris it is recommended that you begin with the previous tutorial:

Note: the instructions below assume you are using MacOS, Ubuntu or Debian.

Edit your function

The bn create node8 hello command that you used in the previous getting-started tutorial creates a file called function.js locally.

exports.handler = async (body, context) => {
  const name = context.request.query.name || body.name || 'World';
  return `Hello ${name}!`;

The function receives two arguments. body holds the HTTP request body, and context holds HTTP request and response parameters (such as query strings and headers). Objects returned from a function are automatically JSON-ified and sent as the HTTP response body.

Modify the code

Change the function.js file for the hello function.

- return `Hello ${name}!`;
+ return `Howdy ${name}!`;

After updating the code the function will need to be deployed again.

$ bn deploy hello
Deployed function hello
Invoke with one of:
  "bn invoke hello"
  "curl -H X-Binaris-Api-Key:$(bn show apiKey) https://run.binaris.com/v2/run/<Your_Account_Number>/hello"

Next, invoke the function to test the changes:

$ bn invoke hello
"Howdy World!"

$ bn invoke hello --data '{"name": "Binaris"}'
"Howdy Binaris!"


You can use bn --help to see all the available CLI commands.

What’s next

Cloud logs