I have two types of http get requests: 1. /abcdocsearch and 2. /reloadList
The /reloadList response is much slower than /abcdocsearch. I want to cancel the /abcdocsearch request if the /reloadList request called after it is already fulfilled.
How can I do this in Javascript. I am using some private libraries to make these calls.
the library internally uses goog.Promise - https://google.github.io/closure-library/api/goog.Promise.html and I can get this promise object.
I tried using goog.Promise.cancel("error")
, however, the request did not get canceled and is still fulfilled.
According to the included API doc, there is no static function called cancel
on goog.Promise
, there is however an instance function on promises' objects, so to cancel a promise, you need to cancel on a promise instance like this
var promise = goog.Promise(/* pass your callbacks here*/);
.
.
.
promise.cancel(/*reason*/);
I highly doubt that if you open the console, you will see an error message like cancel is not defined on goog.Promise
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.