Skip to content

Tie up request and response with unique ID #1182

@MilosMosovsky

Description

@MilosMosovsky

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions