Adding an "after" callback
See original GitHub issueInterceptors are a nice way to add some behaviours before and after a Request. But there is no way to do the same thing for a single resource. There is a callback before
wich is nice to display a loader but there is no after
callback 😦
The idea would be to clone https://github.com/vuejs/vue-resource/blob/master/src/http/interceptor/before.js giving the response as a callback.
I can do the PR myself but I want to know if it would be accepted. Maybe you think people should use their own after
interceptor.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:7 (2 by maintainers)
Top Results From Across the Web
jQuery Insert After Callback? - javascript - Stack Overflow
datetime() is a plugin that I am attaching to an input element with with class date . Obviously #1 doesn't work because that...
Read more >jQuery callbacks.add() Method - GeeksforGeeks
The jQuery callbacks.add() method is used to add a callback or a collection of callbacks to a callback list. This method returns the ......
Read more >JavaScript Callback Functions – What are Callbacks in JS and ...
Callbacks make sure that a function is not going to run before a task is completed but will run right after the task...
Read more >Adding custom callbacks to existing JavaScript functions
This morning I was reading Adding your own callbacks to existing JavaScript functions by Dave Ward—which covers how to overwrite an existing ...
Read more >Advanced Callbacks | Dash for Python Documentation | Plotly
It is possible for a callback to insert new Dash components into a Dash app's layout. If these new components are themselves the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Grafikart Where this code is placed ? thx.
@leixu2txtek you can add it in the main.js like this
Vue.http.interceptors.push((request, next) => { next((response) => { if (request.after) { request.after.call(this, response) } }) })
or create a function like this in the vue-resource.esm.js
function after (request, next) { next((response) => { if (isFunction(request.after)) { request.after.call(this, request);}})}
you need to add these as well
Http.interceptor = {before: before, after: after, method: method, jsonp: jsonp, json: json, form: form, header: header, cors: cors}; Http.interceptors = ['before','after' ,'method', 'jsonp', 'json', 'form', 'header', 'cors'];