Setting Up Mock Server with Postman
The term “mock” means to imitate. During frontend development, to avoid dependency on backend progress, we can set up a mock server based on established API specifications, allowing independent development. Once backend development is complete, we only need to change the request address from the mock server address to the backend service address.
Postman is a powerful API tool that not only allows API debugging but also supports creating mock services. Recently, while working on frontend development, I used Postman to set up mock services and wanted to document the process here.
Postman download address - Click here
Creating Mock Server
Click close, then click to send a single request, and we’ll see the returned result set.
After successfully creating the mock service, it also provides the complete request address. Hover over the address bar ${{url}}
to view it.
Adding Requests
To add requests, click the plus sign to add, then save to the mock collection we just created. Adding return results follows similar operations as the example below for modifying request results.
Modifying Request Result Example
Sometimes you may want to modify the set return results. Click on the example, click on the default example, make your modifications, and save.
Recommended Online Mock Services
Besides setting up mocks with the Postman client, there are also online mock services. Recently I’ve been using easy-mock and find it quite good. I’m sharing it here, and if you know of other good mock services, feel free to leave comments to recommend them to me.
Both local and online mock services have their advantages and disadvantages. Choose the one that best suits your needs.
Final Thoughts
Setting up mock servers with Postman provides a convenient way to simulate API responses during frontend development, allowing teams to work independently without being blocked by backend development progress. The visual interface makes it easy to create and modify mock responses, and the ability to share mock collections with team members enhances collaboration. Whether you choose Postman’s built-in mock server or external services like easy-mock, having a reliable mocking strategy is essential for modern web development workflows.