Access custom logic

You can call a function running on the backend (written via functions module of Space Cloud) from frontend or from some other function on backend by simply calling on frontend. Here's a code snippet showing how to do it:

import { API } from "space-api";

// Initialize api with the project name and url of the space cloud
const api = new API("todo-app", "http://localhost:8080");

// Call a function running 'my-func' of 'my-service' running on backend'my-service', 'my-func', { msg: 'Space Cloud is awesome!' }, 1000)
  .then(res => {
    if (res.status === 200) {
      console.log('Response: ',
  }).catch(ex => {
    // Exception occured while processing request
// Java client coming soon!      
from space_api import API

api = API("books-app", "localhost:8081")
# Call a function, 'my-func' of 'my-engine' running on backend
response ='my-engine', 'my-func', {"msg": 'Space Cloud is awesome!'}, 1000)
if response.status == 200:


The call function takes four arguments which are as follows:

  • serviceName - Name of the service
  • funcName - Name of the function
  • params - An object that can contain any data that you want to pass to the function on backend
  • timeOut - Timeout in milli seconds

As you would have noticed, the above function is asynchronous in nature. The call method triggers the specified function on the backend with the provided params. If the function takes more time to execute than the given timeout, an exception is returned


On response from the server, the callback passed to the then method is called with the response object as described below:

  "status": "number", // Status of the operation
  "data": {
    "result": "object" // Response returned by the function

Next steps

Now you know the basics of all the modules. So let's take a deep dive at securing your app!

Have a technical question?

Edit docs!