You can customize Octokit’s request lifecycle with hooks. Available methods are
octokit.hook.before("request", async (options) => {validate(options);});octokit.hook.after("request", async (response, options) => {console.log(`${options.method} ${options.url}: ${response.status}`);});octokit.hook.error("request", async (error, options) => {if (error.status === 304) {return findInCache(error.headers.etag);}throw error;});octokit.hook.wrap("request", async (request, options) => {// add logic before, after, catch errors or replace the request altogetherreturn request(options);});
See before-after-hook for more details on the 4 methods.