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
Post a Comment