Response Body
Response bodies can either be static or dynamic. Static bodies imply the response being always the same independent of the actual incoming request as long as the related scenario is evaluated as valid.
Static
Below code is an example on a json object to be sent as response. The response could also be as simple as a plain string
.
responseBody: {
username: "rieka",
fullName: "Anna Rieka",
firstName: "Anna",
lastName: "Rieka"
}
Dynamic
During the composition of responses you have access to the request context. You can use requestHeaders
, requestBody
and requestParams
to dynamically compose the response body.
The below example uses requestBody
attributes.
responseBody: (requestHeaders, requestBody, requestParams) => {
username: requestBody.lastName.toLowerCase(),
fullName: `${requestBody.firstName} ${requestBody.lastName}`,
firstName: requestBody.firstName,
lastName: requestBody.lastName
}
👻
Dynamic Response
Open Recipe
Updated almost 3 years ago