DEV Community

Requestly
Requestly

Posted on • Originally published at requestly.com on

1

Simulate Different API status code using Requestly

This article explains how to use Requestly to simulate different API status codes and test your app.

Requestly Browser Extension can simulate different status codes on an API by redirecting the actual API to a mock API.

The mock API simulating the desired status code is hit instead of the actual API. It is done using the redirect rule of requestly.

Create a mock API using Requestly

Requestly has a Mock Server capability to create a Mock API response.

Requestly mock server handles the CORS headers automatically so that the browser does not block the cross-origin requests.

Redirecting the actual API endpoint to the Mock Server endpoint.


Redirect Blinkit Search API to a mock API simulating 404 status code

Removing Content-Security-Policy Headers

Sometimes redirection to mock API won’t work due to Content-Security-Policy- connect-src directive, which restricts the URLs loaded using script interfaces.

You can use the Requestly marketplace rule to bypass this, which is a prebuilt rule to remove the content-security-policy header.


Requestly Marketplace

I hope this empowers you to do robust testing of your frontend by simulating different API behaviours.

Further Resources:

This feature will soon be available on the desktop app. Stay Tuned.

Happy Debugging!

By @nafees87n

Originally published at https://requestly.com.

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs