I have a flask application and i am adding/removing content to the cart via fetch api. When i try to remove the data nothing gets removed.
@cart_bp.route('/cart/action/',methods=['POST'],strict_slashes=False)
def cart():
fetchapi = request.get_json()
if fetchapi['action'].lower() == 'add':
session['cart'].append(fetchapi['item'])
else:
session['cart'].remove(fetchapi['item'])
After I print the session in the else statement the item has been removed. However when I refresh the page or navigate to another page. The cart still contains the item that got removed from the session.