-
Notifications
You must be signed in to change notification settings - Fork 831
Description
Hello @mgonto , i found that you had similiar question here. How to detect from response which request invoked it.
It has a lot of usecases when you need tie-tip request/response with unique ID. For example logging of every query, ajax-loader for corrensponding request.
You told on old issue there is way to send/receive custom headers and read them in interceptor. But i think its not correct way to adjust 3rd party backend to "detect" which request and response are tied when another 3rd library (restangular) is actually invoker of request. Restangular should be responsible to know which request is tied to which response.
What do you think about adding new property (something like requestId) to an element.
function elemFunction(operation, what, params, obj, headers) {
var restangularId = _.uniqueId();
------
var okCallback = function(response) {
_.extend(response, { restangularId : restangularID});
}
var errorCallback = function(response) {
_.extend(response, { restangularId : restangularID});
}
This is solve number one , but if you dont want decorating "response" because response should be response from server, what about manually "injecting" this header inside "headers" object?
For this time i solved it by altering your library but i am asking for official support so i can make PR :)
Let me know what do you think about it.