首页 > 解决方案 > Axios - 主失败时调用辅助 URL

问题描述

有什么方法可以将辅助 url 配置到axios吗?当主 url 失败时,它必须调用辅助 url。

标签: node.jsaxios

解决方案


您可以在第一个的捕获中调用第二个:

      axios
      .get('url')
      .then(response => {
        // handle response
      })
      .catch(error => {
        axios
        .get('url2')
        .then(response => {
          // handle response
        });
      });

推荐阅读