node.js - Axios - 主失败时调用辅助 URL
问题描述
有什么方法可以将辅助 url 配置到axios吗?当主 url 失败时,它必须调用辅助 url。
解决方案
您可以在第一个的捕获中调用第二个:
axios
.get('url')
.then(response => {
// handle response
})
.catch(error => {
axios
.get('url2')
.then(response => {
// handle response
});
});
推荐阅读
- ios - 如何在 React Native 中访问 iOS 用户默认值?
- angular - 如果 rxjs observable 不对变化做出反应,它的目的是什么?
- android - Gradle task to automate release notes from commit message in gradle for Firebase App Distribution dev builds
- elasticsearch - calculate if the timestamp is greater or smaller than current time
- java - Substracting MINUTE from Calender not working correctly
- unity3d - Is there a fast way to detect drag events on a game object in Unity?
- python - to_excel() 没有索引布局
- angular - 动态表的页脚值 - Angular
- javascript - 节点 JS 部署
- node.js - Node.js:将 Cucumber JSON 结果发送到 Jira 的 Xray - jira-client-xray 给出 HTTP 405 错误