Comments (18)
Google brought me here, but es6 does support finally
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/finally.
Should this issue be reopened to add support for .finally
?
from axios.
FYI for anyone that comes here in the future .finally()
does now work with axios.
from axios.
from axios.
The docs says:
axios.get('/user')
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
})
.then(function () {
// always executed
});
So I recon "always executed" already works the same as this proposed "finally" or am I missing something?
from axios.
Doesn't that effectively mean that if you want to add finally
to axios, then all you need to do it is to shim es6-promise
with the aforementioned library? Ie. you would do:
var axios = require('axios');
require('promise.prototype.finally');
...
If so, it's probably better leave it out of the core library and just document that this is possible. That way you don't bloat the current implementation while keeping options open for people that might want the feature.
from axios.
Suggest adding some comment like similar to finally in other libraries
because I was searching for finally
and the search didn't bring me to the code snippet. Not everyone necessarily read thru the doc.
from axios.
finally
has been working fine for me, except (it appears) for Safari Version 10 and 11. I'm seeing
TypeError undefined is not a function (near '...{alert(e)})).finally((function(){e.setSt...')
Do I need to switch to using then
, or should I add the polyfill instead?
from axios.
I'm reluctant to implement this. The ES6 Promise spec doesn't support finally
, and I want to be able to drop the polyfill when browsers have native support.
If you feel strongly, or if I'm missing something, please present your argument.
from axios.
@bebraw yes exactly. The es6-promise
polyfill uses the native Promise
if it exists. In either case the finally
shim will work as you indicated. Let's leave it out of axios and let others add it to their own project if they desire.
I am working on axios today. I can add some documentation about this to the README
.
from axios.
I have solved this issue, by just include polyfill file from CDN
<script src="https://polyfill.io/v3/polyfill.min.js?features=Promise.prototype.finally" defer></script>from axios.
I found an npm module a few months ago which adds finally
support to promises. I don't think this is the one, but it's the only one I found after a minute of searching: https://www.npmjs.com/package/promise.prototype.finally
from axios.
well ok then @jmdobry π
from axios.
I want to be able to drop the polyfill when browsers have native support.
π
from axios.
The docs says:
axios.get('/user') .then(function (response) { console.log(response); }) .catch(function (error) { console.log(error); }) .then(function () { // always executed });
So I recon "always executed" already works the same as this proposed "finally" or am I missing something?
As per the docs that's what I have used. However, I have a question.
What happens if I just want to use the "always executed then" because I don't really care for the reply?.
from axios.
after add this ployfill:
const promiseFinally = require('promise.prototype.finally')
promiseFinally.shim()
finally
function was added to the Promise.prototype
from axios.
I see Promise.finally is available in Node 10. Been a while since I tried this, but maybe this just works if you're using Node 10?
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/finally
from axios.
Not one soul writes the current status here.
The syntax finally is supported in browsers now.
Also axios supports it.
from axios.
march 2020. Finally work in safari + safari mobile
from axios.
Related Issues (20)
- Using HTTP proxy for HTTPS address does not start a HTTP Connection HOT 1
- Cannot see the Axios result in the then, catch, and finally methods.
- CSRF Token Mismatch HOT 4
- [fatal][nodejs] βError: Unexpected end of formβ after multiple post file formdata, and then hang up after multiple error happening HOT 3
- "Class extends value #<newConstructor> is not a constructor or null" when sending request from node.js 20.12.0
- [0.28.1] options.paramsSerializer as function don't work HOT 2
- vite5+vue3+ts Sending request error SyntaxError: The requested module '/node_modules/.vite/deps/axios.js?v=bc297318' does not provide an export named 'AxiosInstance' HOT 1
- Issue CVEs for vulnerabilities fixed by #6167 and #6163
- How to set localAddress when sending HTTP requests? HOT 2
- API call happening twice, but called once! HOT 3
- RefferenceError: Axios is not defined. HOT 2
- Security vulnerability
- postForm's form-data serialization breaks for Blob in Node.js
- Axios stream aborts early during 204 response from prism cli.
- I am getting a error involving CancelToken.js...
- TypeError: Converting circular structure to JSON
- React native Android NETWORK ERROR
- Issue with downloading files larger than a few mbs on Chrome specifically
- please expose the formDataToStream for public use
- 100% Upload progress on dev mode only.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from axios.