Modify Response - FAQs
Everything you need to know so you can modify response like a pro

What all types of responses can be modified using this rule?

Using desktop app, all kinds of responses(APIs, JS, HTML, CSS etc.) can be modified.
Chrome Extension only supports modification of API responses triggered by XMLHttpRequest (XHR) or fetch. Requests made by jQuery AJAX or Axios is also supported in the Chrome extension. For any other resource type like HTML, JS you can use the desktop app.

How to target a particular API?

We use request URL matching pattern. You can set the request URL to match, contain some specific expression or a regex expression to target a particular API. Read more here

Can I get more control by targeting a particular HTTP method like GET, POST etc.

Yes, you can get more control by using the source filter where you can specify which resource type or request method to target. GraphQL APIs can be targetted with request payload.
The source filter menu can be opened by clicking the filter icon beside URL matching field.
Source filters

Can I modify the status code of a response?

Yes. It can be done very easily using the Requestly Desktop App. You just have to mention the status code you want to simulate in the modify response rule. Refer the demo here.
It can also be done using the requestly browser extension by using a redirect rule to redirect the actual request to a mock API which returns the desired status code. Read more here.

Can headers be modified using modify response rule?

No, you can only get the request headers in JS mode but cannot modify them. To modify headers, modify headers rule should be used.

What are the different ways to modify the response?

Response can be modified by sending a JSON or by programatically modifying the response using Javascript.
Desktop app also offers the capability to serve response JSON from a local file on your system.
Serving from local file

What are some of the common mistakes done by users when using this rule?

When modifying the response, users try assigning to a constant variable which is not allowed.

How to check console.log in the desktop app?

Developer tools can be toggled in the desktop app from the view menu. Logs can be checked in the devtool's console.
Toggling devtools

Does serving response JSON from local file change the JSON when file is edited locally?

Yes

Can graphql API responses be modified?

Yes graphql API requests can be targeted using the request payload source filter in the modify response rule. Read more