Getting Started
Getting Started
Installation
Installation
Inspect Traffic
Inspect Traffic
HTTP Rules (Modify Traffic)
HTTP Rules (Modify Traffic)
Overview
Redirect URL (Map Local, Map Remote)
Replace Strings (Switch Hosts, API Endpoints)
Modify Headers
Modify Request Body
Modify Response Body
Modify Query Params
Modify Cookies
Modify DOM/Inject scripts
Modify User Agents
Delay Request
Cancel Rule
Organizing Rule
Import/Export Rules from File
Pause/Resume Requestly
Rule Operators
Advance Targeting
Sharing Rules
Map Local
Map Remote
Pinning Rules
GraphQL Support
Edit and Replay
Import Setting from Charles Proxy
Test URL Condition
Test this Rule
File Server
File Server
Sessions Replay
Sessions Replay
Getting Started
Getting Started
Installation
Installation
Inspect Traffic
Inspect Traffic
HTTP Rules (Modify Traffic)
HTTP Rules (Modify Traffic)
Overview
Redirect URL (Map Local, Map Remote)
Replace Strings (Switch Hosts, API Endpoints)
Modify Headers
Modify Request Body
Modify Response Body
Modify Query Params
Modify Cookies
Modify DOM/Inject scripts
Modify User Agents
Delay Request
Cancel Rule
Organizing Rule
Import/Export Rules from File
Pause/Resume Requestly
Rule Operators
Advance Targeting
Sharing Rules
Map Local
Map Remote
Pinning Rules
GraphQL Support
Edit and Replay
Import Setting from Charles Proxy
Test URL Condition
Test this Rule
File Server
File Server
Sessions Replay
Sessions Replay
ย
Before going into Async Modifications, lets learn about Requestly Response Rule a little bit.
Requestly Response Ruleย comes in handy when you have to modify the response of a Request. You can either modify the response usingย
Static Dataย orย Programmaticallyย write a script to modify the response.Programmatic Response Rule
Modifying Response body using Programmatic mode is really powerful. You can modify the response body programmatically based on incoming request's headers, status code, request method etc.
For example, this rule changes the response body toย
{"foo": "bar"}ย when request method isย GETย and return original response for rest of the methods.function modifyResponse(args) { const {method, url, response, responseType, requestHeaders, requestData, responseJSON} = args; // Change response below depending upon request attributes received in args if(method === "GET") { return {"foo": "bar"} } return response; }
Async Modifications
Async modifications lets you perform some long running tasks before returning the response. You can learn about async await fromย here. This can be helpful in the following scenarios:
In Extension, async/await will work only for requests made usingยfetch
ย
Usecases
- Adding delays in Response (This is also possible usingย Requestly Delay Rule)
ย
Example 1
In this example, we'll try to hit an external URL to fetch the auth_token and then add the token in the original response.



ย
- Fetching Token from URLย
https://demo_requestly.requestly.dev/auth_token.
- Adding token in Response.
ย
Example 2
This example changes the response of a non-existent domain (https://non-existent-url.com) by fetching the response from another url (https://demo_requestly.requestly.dev/users/1)
ย



ย
ย