Steps to conditionally fail requests are:
Enable Dynamic JavaScript Modification
Choose the Dynamic JavaScript option to write custom logic for the response.
$sharedState is only available in extension versions > v24.8.13 and desktop app versions > v1.7.1.Enable Dynamic JavaScript Modification
Add JavaScript to Control Response Based on Request Count
function modifyResponse(args) {
const {
method, url, response, responseType,
requestHeaders, requestData, responseJSON
} = args;
// Get the current count or start from 0
let count = $sharedState.count ?? 0;
count++;
$sharedState.count = count;
// Succeed if it is not the first request
if (count > 1) {
return null;
}
// Allow all subsequent requests to succeed
return response;
}