Using the WixHttpFunctionResponse
object, you define an appropriate response after the handling of an
incoming request. There are a number of functions
you can use to create the WixHttpFunctionResponse
, such as:
To define the response, set the body
, headers
, and status
properties.
Notes:
This API is only intended for use in server-to-server communications. If you use this API to set a cookie on a site visitor's browser you may no longer be in compliance with applicable data privacy regulations.
All of the above functions except response()
always create a response object with a pre-set HTTP status code (e.g. for ok()
this is always 200), which cannot be overridden.
Sets or gets the body of the response as a string, object or binary buffer.
// In http-functions.js
export function use_myFunction(request) {
let body = response.body; // "body text"
}