Post Function: Modify Mock API Responses in mockforme
The Post Function feature in mockforme allows you to modify your API response before it's sent to the client. This provides you with full flexibility to transform the response data based on specific conditions and custom logic.
info
The Post Function runs on a Node.js runtime, enabling you to write scripts that dynamically change mock API behavior.
Accessing the Post Function
To access the Post Function, follow these steps:
- Navigate to the API Response page.
- Look for the Post Function button in the UI, as shown below:

Supported System Variables for Post Function
You can use several system variables provided by mockforme within the Post Function:
// Access query parameters
mfm.query
// Access request body (for POST/PUT methods)
mfm.body
// Access or modify the response data
mfm.data