diff --git a/src/services/feature-api.js b/src/services/feature-api.js index f933884cc70b32d9fca07e5ec5331950a1b31ae6..d5e6c4271b53ff52ab0e3adc52c7c5ac0fa9785a 100644 --- a/src/services/feature-api.js +++ b/src/services/feature-api.js @@ -37,7 +37,12 @@ const featureAPI = { }, async getPaginatedFeatures(url) { - const response = await axios.get(url); + // Cancel any ongoing search request. + store.dispatch('CANCEL_CURRENT_SEARCH_REQUEST'); + // Prepare the cancel token for the new request and store it. + const cancelToken = axios.CancelToken.source(); + store.commit('SET_CANCELLABLE_SEARCH_REQUEST', cancelToken); + const response = await axios.get(url, { cancelToken: cancelToken.token }); if ( response.status === 200 && response.data