Created
April 23, 2025 19:05
-
-
Save bel0v/a5dadb1d32c94ae41e745d7ac6e7c7b3 to your computer and use it in GitHub Desktop.
Trace object methods caller via proxy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const bodyReadingMethods = ['arrayBuffer', 'blob', 'formData', 'text', 'json'] | |
bodyReadingMethods.forEach((methodName) => { | |
request[methodName] = new Proxy(request[methodName], { | |
apply(...args) { | |
console.trace(`"request.${methodName}" call!`) | |
return Reflect.apply(...args) | |
}, | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment