Guides  ›  Routes  ›  Actions ← PREV NEXT →

Actions

An action can read POST parameters and return JSON.

// app/actions/greet.js
module.exports = {
  paths: '/greet',
  methods: 'POST',
  handler: function (state) {
    var name = state.req.body.params.name
    return state.jarpc({ ok: true, message: 'Hello ' + name })
  }
}
curl http://localhost:3000/greet \
  -H 'content-type: application/json' \
  -d '{"id":"1","params":{"name":"Jack"}}'

Next: Paths →

Tools for business systems.