admin管理员组文章数量:1297094
I am using axios in one of my Vue.js project. I am performing some operations no matter if an API call fails or pletes. I came to know about finnaly()
method.
It is being executed after the API request either fails or succeeds.
But I am not getting response object in callback given to finally.
For Example:
axios()
.then((response) => {
console.log(response); // response object defined
//handle response on success
return response
}).finally((response) => {
console.log(response); // response object undefined
});
I am using axios in one of my Vue.js project. I am performing some operations no matter if an API call fails or pletes. I came to know about finnaly()
method.
It is being executed after the API request either fails or succeeds.
But I am not getting response object in callback given to finally.
For Example:
axios()
.then((response) => {
console.log(response); // response object defined
//handle response on success
return response
}).finally((response) => {
console.log(response); // response object undefined
});
Share
edited Feb 7, 2019 at 8:39
Billal BEGUERADJ
22.8k45 gold badges123 silver badges140 bronze badges
asked Feb 7, 2019 at 8:35
Amarjit SinghAmarjit Singh
2,1541 gold badge24 silver badges54 bronze badges
2 Answers
Reset to default 7The Promise.finally method does not give arguments to the callback
Read MDN [ https://developer.mozilla/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/finally ]
You could use .then again to get the response.
I solved it by including polyfill.finally script:
<script src="https://polyfill.io/v3/polyfill.min.js?features=Promise.prototype.finally" defer></script>
本文标签: javascriptaxios response object in finally callback is undefinedStack Overflow
版权声明:本文标题:javascript - axios response object in finally callback is undefined - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741629307a2389264.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论