# Response Instance

The res object represents the HTTP response that an RELE.AI app sends when it gets an HTTP request.

In this documentation and by convention, the object is always referred to as res (and the HTTP request is req) but its actual name is determined by the parameters to the callback function in which you’re working.

# For Example:

// register the hello_world operation
router.use("hello_world", (req, res) => {
    res.send(200, { message: "Hello World!" })
})

# But you could just as well have:

router.use("hello_world", (request, response) => {
    response.send(200, { message: "Hello World!" })
})

# Methods

# res.send

Send method Sends the HTTP response.

Send takes two parameters.

  1. statusCode - The response code status
  2. responseObject - The response object
router.use("hello_world", (req, res) => {
  try {
    // pull data from remote api
    const dataObj = await api.getData(req.payload.userId)

    // send as response
    res.send(200, dataObj)
  } catch (e) {
    // return an error
    res.send(
      400,
      { error: e.message || "unable to complete opeartion" }
    )
  }
})