不确定我错过了什么。按照此处的说明进行操作:https://github.com/mzabriskie/axios/blob/master/COOKBOOK.md
我已经 npm 安装了 axios 和 npm install axios promise.prototype.finally --save
。
我正在使用 Gulp 和 Browserify。
var axios = require('axios');
require('promise.prototype.finally');
axios.get('http://google.com').finally(function(){
console.log('test');
});
错误:
app-7ee90adab7.js:18780 Uncaught TypeError: axios.get(...).finally is not a function
更新: 这使其有效,但我需要这样做吗?
var promiseFinally = require('promise.prototype.finally');
promiseFinally.shim();
最佳答案
仅供引用 https://github.com/axios/axios/issues/34#issuecomment-558869934
Axios 支持.finally()
。
关于javascript - 带有 promise.prototype.finally 的 Axios 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39696007/