orderiom-api-package 0.4.94 → 0.4.95
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/common.js +16 -3
package/package.json
CHANGED
package/src/common.js
CHANGED
|
@@ -149,13 +149,17 @@ const getAuthToken = async ($store, hadPrivateToken = false) => {
|
|
|
149
149
|
|
|
150
150
|
if(hadPrivateToken) {
|
|
151
151
|
$store.commit("auth/clearAuthData");
|
|
152
|
-
await $store.dispatch('unassignBasket');
|
|
152
|
+
await $store.dispatch('auth/unassignBasket');
|
|
153
153
|
}
|
|
154
154
|
} catch (error) {
|
|
155
155
|
return commonErrorCallback()(error)
|
|
156
156
|
} finally {
|
|
157
157
|
while (reqBuffer.length) {
|
|
158
|
-
|
|
158
|
+
let basketId = null;
|
|
159
|
+
if(hadPrivateToken){
|
|
160
|
+
basketId = calculateBasketIdParameter(false, restaurantIdEnv())
|
|
161
|
+
}
|
|
162
|
+
reqBuffer.shift()(basketId); // First in First out
|
|
159
163
|
}
|
|
160
164
|
isFetchingToken = false;
|
|
161
165
|
}
|
|
@@ -190,10 +194,19 @@ export const defineInterceptors = ({$store}) => {
|
|
|
190
194
|
localStorage.removeItem("publicToken");
|
|
191
195
|
|
|
192
196
|
// Push the request to waitlist and wait for new token to be fetched
|
|
193
|
-
reqBuffer.push(() => {
|
|
197
|
+
reqBuffer.push((basketId = null) => {
|
|
194
198
|
const newToken = localStorage.getItem("publicToken");
|
|
195
199
|
if(newToken){
|
|
196
200
|
config.headers["Authorization"] = `Bearer ${newToken}`
|
|
201
|
+
|
|
202
|
+
// basketId is available only when unassign-basket is called right before resolving the request from waitlist
|
|
203
|
+
if(basketId){
|
|
204
|
+
const key = config.method === 'get' ? 'params' : 'data';
|
|
205
|
+
const data = config[key] || {};
|
|
206
|
+
if(!data.basketId) data.basketId = basketId;
|
|
207
|
+
config[key] = data;
|
|
208
|
+
}
|
|
209
|
+
|
|
197
210
|
resolve(config);
|
|
198
211
|
} else {
|
|
199
212
|
config.headers["Authorization"] = undefined;
|