Response payload
In the response payload editor you can either:
- Specify the mock response to change the response data.
- Forward the original response (only available on paid plans). Upon selecting a modify rule, if you empty the editor, tweak will forward the original HTTP response to the application. This can be useful if you want to modify only HTTP headers or manipulate the original response data with custom JavaScript.
caution
To forward the original HTTP response, the editor must be totally empty (no white spaces).
The response payload editor adapts to the content-type
header under the response headers tab. Here are the supported types:
- JSON - most of the times, developers deal with JSON data. If the
content-type
isapplication/json
, the JSON language will be enabled in the editor. Furthermore, tweak only serializes/deserializes mock data in JSON when provided thecontent-type: application/json
. Because this is the most common data type, it is the default value when you create a new rule. - JavaScript - for cases where the
content-type
containsapplication/javascript
, the JavaScript language support is enabled for a better experience. - For all other use cases, the editor falls back to plain text (e.g.
content-type
value set totext/plain
or others).
Additional features​
- To test your application you can send invalid response payloads (e.g. white spaces, malformed JSON etc.). This feature was introduced in tweak v1.1.0.
- You can reference variables and use data generators in this editor.