-
Notifications
You must be signed in to change notification settings - Fork 31
Open
Description
Currently to cancel a request made by commerce-sdk-isomorphic the only way is to include AbortSignal in clientConfiguration.fetchOptions, but that uses the same signal for all requests. Although it is usable it requires to create separate client for each scope where requests may need to be canceled.
Instead if AbortSignal could be provided when executing an api call it will allow to reuse clients within subscopes and each request may have separate signal.
Example usage:
// client created globally
const client = new ShopperSearch(clientConfig)
function doSearch(query) {
// cancel previous search in progress
if (this.abortController) {
this.abortController.abort()
}
// make new search request with new abort controller
this.abortController = new AbortController()
return this.client.productSearch({
parameters: { q: query },
headers: { authorization: /* ... */ },
signal: this.abortController.signal,
})
}Metadata
Metadata
Assignees
Labels
No labels