How to obtain response uniformly by node.js

there are many methods in the project to request the interface, and sometimes the token expires, so it needs to be judged and processed in each method. Is there any way for node.js to obtain the response, uniformly and then deal with it?

the foreground ajax requests the node interface. Node uses superagent to request the API interface. API returns Token expiration. Can superagent handle it uniformly at this time

Mar.01,2021

for your description, I am very confused. Is the response obtained by requesting node through ajax in the project token expired, or is node to request other interfaces and return token expiration?

as far as I understand it, you should unify error handling at the request of ajax. Then you can consider axios axios document

// 
axios.interceptors.request.use(function (config) {
    // 
    return config;
  }, function (error) {
    // 
    return Promise.reject(error);
  });

// 
axios.interceptors.response.use(function (response) {
    // 
    return response;
  }, function (error) {
    // 
    return Promise.reject(error);
  });
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b36a8c-2c03b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b36a8c-2c03b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?