javascript - How to attach data to fetch() request and get it back with response? -


is possible fetch() api attach arbitrary client-only data request , access response?

i need attach sequence number each request particular endpoint , need somehow available through corresponding response (in order know when silently drop response "superseded" request), neither need nor want send seq number server , require server return it.

just store in closure:

var seq = 0; function makerequest() {     var cur = ++seq;     return fetch(…).then(function(response) {         if (cur < seq)             throw new error("has been superseded");         else             return response.json();     }); } 

Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -