diff --git a/scripts/wishlist/api.js b/scripts/wishlist/api.js index ac05f376e1..1a75eed08b 100644 --- a/scripts/wishlist/api.js +++ b/scripts/wishlist/api.js @@ -52,7 +52,10 @@ mutation( `; export async function getWishlists() { - const token = getSignInToken(redirectToSignin); + const token = getSignInToken(); + if (!token) { + redirectToSignin(); + } const wishlists = await performMonolithGraphQLQuery( getWishlistsQuery, @@ -75,8 +78,12 @@ export async function getWishlists() { * @returns {Promise} */ export async function addToWishlist(product, wishlistId) { + const token = getSignInToken(); + if (!token) { + redirectToSignin(); + } + const toWishlist = wishlistId ?? (await getWishlists())[0].id; - const token = getSignInToken(redirectToSignin); const response = await performMonolithGraphQLQuery( addProductToWishlistMutation,