Add debugFetch wrapper in log.js that logs method, URL, and body on request, and status code on response. Replace all fetch() calls across balances, transactions, tokens, background RPC proxy, and settings validation with debugFetch.
This commit is contained in:
@@ -27,4 +27,14 @@ const log = {
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = { log };
|
||||
// Fetch wrapper that debug-logs every request and response.
|
||||
async function debugFetch(url, opts) {
|
||||
const method = (opts && opts.method) || "GET";
|
||||
const body = opts && opts.body;
|
||||
log.debugf("fetch →", method, url, body || "");
|
||||
const resp = await fetch(url, opts);
|
||||
log.debugf("fetch ←", resp.status, url);
|
||||
return resp;
|
||||
}
|
||||
|
||||
module.exports = { log, debugFetch };
|
||||
|
||||
Reference in New Issue
Block a user