Skip to content

Instantly share code, notes, and snippets.

@bel0v
Created April 23, 2025 19:05
Show Gist options
  • Save bel0v/a5dadb1d32c94ae41e745d7ac6e7c7b3 to your computer and use it in GitHub Desktop.
Save bel0v/a5dadb1d32c94ae41e745d7ac6e7c7b3 to your computer and use it in GitHub Desktop.
Trace object methods caller via proxy
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