Not sure what I am missing. Following the instructions here: https://github.com/mzabriskie/axios/blob/master/COOKBOOK.md
I have npm installed both axios and npm install axios promise.prototype.finally --save
.
I am using Gulp with Browserify.
var axios = require('axios');
require('promise.prototype.finally');
axios.get('http://google.com').finally(function(){
console.log('test');
});
Error:
app-7ee90adab7.js:18780 Uncaught TypeError: axios.get(...).finally is not a function
Update: This makes it work but do I need to do this?
var promiseFinally = require('promise.prototype.finally');
promiseFinally.shim();
Try one of these see if it works:
See if you have a global Promise available to shim it? Enter Promise
in chrome console while the browserify is running the bundle. If you don't have it, use Babel or a lib that makes es6 or just Promise available.
If it didn't work for some reason... well axios cookbook.md didn't get it right, since you have to call shim() to apply it on promise proto. why don't you use a shorthand require('promise.prototype.finally').shim();
if you don't like it that way, otherwise you have to require('es6-shim');
FYI https://github.com/axios/axios/issues/34#issuecomment-558869934
Axios supports .finally()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With