Axios - 当主 URL 失败时调用辅助 URL

Mit*_*G S 4 node.js axios

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

小智 5

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

      axios
      .get('url')
      .then(response => {
        // handle response
      })
      .catch(error => {
        axios
        .get('url2')
        .then(response => {
          // handle response
        });
      });
Run Code Online (Sandbox Code Playgroud)