@@ -107,7 +107,8 @@ And that's our callback for applying the our session token to each request made
107107import { ApolloLink } from ' @apollo/client' ;
108108
109109const consoleLink = new ApolloLink ((operation , forward ) => {
110- return operation .setContext (/* our callback */ );
110+ operation .setContext (/* our callback */ );
111+ return forward (operation);
111112});
112113```
113114
@@ -294,7 +295,7 @@ Next, define the `createUpdateLink` function as follows:
294295` ` ` javascript
295296import { setContext } from ' @apollo/client/link/context' ;
296297
297- function createUpdateLink (operation , forward ) => {
298+ function createUpdateLink (operation , forward ) {
298299 return forward (operation).map ((response ) => {
299300 /**
300301 * Check for session header and update session in local storage accordingly.
@@ -303,10 +304,8 @@ function createUpdateLink(operation, forward) => {
303304 const { response: { headers } } = context;
304305 const oldSessionToken = localStorage .getItem (process .env .SESSION_TOKEN_LS_KEY as string);
305306 const sessionToken = headers .get (' woocommerce-session' );
306- if (sessionToken) {
307- if ( oldSessionToken !== session ) {
308- localStorage .setItem (process .env .SESSION_TOKEN_LS_KEY as string, sessionToken);
309- }
307+ if (sessionToken && sessionToken !== oldSessionToken) {
308+ localStorage .setItem (import .meta.env.PUBLIC_SESSION_TOKEN_LS_KEY as string , sessionToken);
310309 }
311310
312311 return response;
0 commit comments