Still showing old data that doesn't exist on page using IE









up vote
1
down vote

favorite












Hi I am building a shopping cart and ran into problems on IE.(note everything works as expected on other browsers).



So my problem is for ex:
I have 5 items in a cart I click remove item on 1 item.
I refresh the page and that item is still there.
When I check my database for that item it doesn't exists anymore so it was deleted. So why am I still seeing that item that was deleted on the page?
This only happens in IE.



my component looks like this



class Cart extends Component 
componentDidMount()
console.log('executed') //I get executed in the console so that works.
this.props.fetchCart();


removeItem(productId)
this.props.dispatch(removeItem(productId));


render()
return (
<ul className='list-item'>

cart.items.map((item, index) =>
return (
<li className='list-group-item d-flex justify-content-between align-items-center' key=index>
<img style= width: '150px', height: '100px' src=item.main_img />
<h5>item.title</h5>
<small>quantity item.quantity</small>
<small>Price $item.price</small>
<button
onClick=() => this.removeItem(item.product_id)>Remove</button>
</li>
)
)

</ul>
)



const mapStateToProps = (state) =>
console.log(state.cart) //Always get 5 items instead of 4 which I should get 4 cause I deleted 1
return
cart: state.cart



const mapDispatchToProps = (dispatch) =>
return bindActionCreators( dispatch, rmAlert , dispatch);


export default connect(mapStateToProps, mapDispatchToProps)(Cart);


my saga for fetchCart:



 import call, put, takeLatest from 'redux-saga/effects';
import FETCH_CART from '../../constants/cart';
import fetchedCartSuccessful, fetchedCartError from
'../../actions/cart';
import axios from 'axios';

function* fetchCart()
try
const response = yield call([axios, axios.get], '/api/cart');

yield put(fetchedCartSuccessful(response.data));
catch (e)
yield put(fetchedCartError(e.response.data));



export function* watchFetchCart()
yield takeLatest(FETCH_CART, fetchCart);



and my saga for removeItem



 import call, put, takeLatest from 'redux-saga/effects';
import showAlert, rmAlert from '../../actions/alert';
import REMOVE_ITEM_IN_CART from '../../constants/cart';
import fetchCart from '../../actions/cart';
import axios from 'axios';

function* removeItemInCart(action)
yield put(rmAlert());

let alert = ;

try
const response = yield call([axios, axios.post], '/cart/remove-item',
productId: action.productId
);

alert.alertClass = 'alert-success';
alert.msg = response.data.success.msg;

yield put(fetchCart());
yield put(showAlert(alert));
catch (e)
alert.alertClass = 'alert-info';
alert.msg = e.response.data.error.msg;

yield put(showAlert(alert));



export function* watchRemoveItemInCart()
yield takeLatest(REMOVE_ITEM_IN_CART, removeItemInCart)



On my back end where I grab the cart from mysql database and send it back in a response. I console.log('executing') to make sure it is executing and no console.log is shown in the console? I have no idea whats going on. Again this works as expected on chrome and Firefox.



 app.get('/api/cart', (req, res) => 
const userId = req.signedCookies['user_cookie'];
console.log('executing'); //no console log saying this executed ?

const sql = `SELECT *, cart.quantity * products.price as price
FROM cart
LEFT JOIN products ON products.product_id = cart.product_id
WHERE user_id='$userId'`;

connection.query(sql, (err, result, fields) =>
if (err)
return res.status(500).json(
error:
msg: 'Something went wrong, couldn't GET cart'

);


let cart = quantity: 0, total: 0, items: ;

result.map(item =>
cart.quantity += item.quantity;
cart.total += item.price;
cart.items.push(item);
);
console.log(cart);
res.setHeader('content-type', 'text/javascript');
res.send(cart);
);
);


how do I check how many items should be in my cart? I do that below by visiting this route



 app.get('/all-carts', (req, res) => 
console.log(req.signedCookies['user_cookie'])
const sql = `SELECT * FROM cart`;

connection.query(sql, (err, results, feilds) =>
console.log(results);
res.setHeader('content-type', 'text/javascript');
res.send(results);
);
);


I visit that route and I get a response with an array of 4 items as expected cause I deleted 1. If I delete all the items I see an empty array. Yet when I view cart page I see 5 items being displayed still?



UPDATE -- when I clear browser history it shows the correct amount of items in the cart why do I have to clear browser history to see any updates on IE?










share|improve this question























  • What does removeItem() and fetchCart() does in your code? Please share that too
    – Hemadri Dasari
    Nov 9 at 20:52











  • ok give me a min
    – radlaz
    Nov 9 at 20:54










  • I added my sagas that deal with that. On the backend for remove Item I do a MySQL delete statement I delete the row which columns product_id=the_product_id and user_id=the_user_id,
    – radlaz
    Nov 9 at 21:03















up vote
1
down vote

favorite












Hi I am building a shopping cart and ran into problems on IE.(note everything works as expected on other browsers).



So my problem is for ex:
I have 5 items in a cart I click remove item on 1 item.
I refresh the page and that item is still there.
When I check my database for that item it doesn't exists anymore so it was deleted. So why am I still seeing that item that was deleted on the page?
This only happens in IE.



my component looks like this



class Cart extends Component 
componentDidMount()
console.log('executed') //I get executed in the console so that works.
this.props.fetchCart();


removeItem(productId)
this.props.dispatch(removeItem(productId));


render()
return (
<ul className='list-item'>

cart.items.map((item, index) =>
return (
<li className='list-group-item d-flex justify-content-between align-items-center' key=index>
<img style= width: '150px', height: '100px' src=item.main_img />
<h5>item.title</h5>
<small>quantity item.quantity</small>
<small>Price $item.price</small>
<button
onClick=() => this.removeItem(item.product_id)>Remove</button>
</li>
)
)

</ul>
)



const mapStateToProps = (state) =>
console.log(state.cart) //Always get 5 items instead of 4 which I should get 4 cause I deleted 1
return
cart: state.cart



const mapDispatchToProps = (dispatch) =>
return bindActionCreators( dispatch, rmAlert , dispatch);


export default connect(mapStateToProps, mapDispatchToProps)(Cart);


my saga for fetchCart:



 import call, put, takeLatest from 'redux-saga/effects';
import FETCH_CART from '../../constants/cart';
import fetchedCartSuccessful, fetchedCartError from
'../../actions/cart';
import axios from 'axios';

function* fetchCart()
try
const response = yield call([axios, axios.get], '/api/cart');

yield put(fetchedCartSuccessful(response.data));
catch (e)
yield put(fetchedCartError(e.response.data));



export function* watchFetchCart()
yield takeLatest(FETCH_CART, fetchCart);



and my saga for removeItem



 import call, put, takeLatest from 'redux-saga/effects';
import showAlert, rmAlert from '../../actions/alert';
import REMOVE_ITEM_IN_CART from '../../constants/cart';
import fetchCart from '../../actions/cart';
import axios from 'axios';

function* removeItemInCart(action)
yield put(rmAlert());

let alert = ;

try
const response = yield call([axios, axios.post], '/cart/remove-item',
productId: action.productId
);

alert.alertClass = 'alert-success';
alert.msg = response.data.success.msg;

yield put(fetchCart());
yield put(showAlert(alert));
catch (e)
alert.alertClass = 'alert-info';
alert.msg = e.response.data.error.msg;

yield put(showAlert(alert));



export function* watchRemoveItemInCart()
yield takeLatest(REMOVE_ITEM_IN_CART, removeItemInCart)



On my back end where I grab the cart from mysql database and send it back in a response. I console.log('executing') to make sure it is executing and no console.log is shown in the console? I have no idea whats going on. Again this works as expected on chrome and Firefox.



 app.get('/api/cart', (req, res) => 
const userId = req.signedCookies['user_cookie'];
console.log('executing'); //no console log saying this executed ?

const sql = `SELECT *, cart.quantity * products.price as price
FROM cart
LEFT JOIN products ON products.product_id = cart.product_id
WHERE user_id='$userId'`;

connection.query(sql, (err, result, fields) =>
if (err)
return res.status(500).json(
error:
msg: 'Something went wrong, couldn't GET cart'

);


let cart = quantity: 0, total: 0, items: ;

result.map(item =>
cart.quantity += item.quantity;
cart.total += item.price;
cart.items.push(item);
);
console.log(cart);
res.setHeader('content-type', 'text/javascript');
res.send(cart);
);
);


how do I check how many items should be in my cart? I do that below by visiting this route



 app.get('/all-carts', (req, res) => 
console.log(req.signedCookies['user_cookie'])
const sql = `SELECT * FROM cart`;

connection.query(sql, (err, results, feilds) =>
console.log(results);
res.setHeader('content-type', 'text/javascript');
res.send(results);
);
);


I visit that route and I get a response with an array of 4 items as expected cause I deleted 1. If I delete all the items I see an empty array. Yet when I view cart page I see 5 items being displayed still?



UPDATE -- when I clear browser history it shows the correct amount of items in the cart why do I have to clear browser history to see any updates on IE?










share|improve this question























  • What does removeItem() and fetchCart() does in your code? Please share that too
    – Hemadri Dasari
    Nov 9 at 20:52











  • ok give me a min
    – radlaz
    Nov 9 at 20:54










  • I added my sagas that deal with that. On the backend for remove Item I do a MySQL delete statement I delete the row which columns product_id=the_product_id and user_id=the_user_id,
    – radlaz
    Nov 9 at 21:03













up vote
1
down vote

favorite









up vote
1
down vote

favorite











Hi I am building a shopping cart and ran into problems on IE.(note everything works as expected on other browsers).



So my problem is for ex:
I have 5 items in a cart I click remove item on 1 item.
I refresh the page and that item is still there.
When I check my database for that item it doesn't exists anymore so it was deleted. So why am I still seeing that item that was deleted on the page?
This only happens in IE.



my component looks like this



class Cart extends Component 
componentDidMount()
console.log('executed') //I get executed in the console so that works.
this.props.fetchCart();


removeItem(productId)
this.props.dispatch(removeItem(productId));


render()
return (
<ul className='list-item'>

cart.items.map((item, index) =>
return (
<li className='list-group-item d-flex justify-content-between align-items-center' key=index>
<img style= width: '150px', height: '100px' src=item.main_img />
<h5>item.title</h5>
<small>quantity item.quantity</small>
<small>Price $item.price</small>
<button
onClick=() => this.removeItem(item.product_id)>Remove</button>
</li>
)
)

</ul>
)



const mapStateToProps = (state) =>
console.log(state.cart) //Always get 5 items instead of 4 which I should get 4 cause I deleted 1
return
cart: state.cart



const mapDispatchToProps = (dispatch) =>
return bindActionCreators( dispatch, rmAlert , dispatch);


export default connect(mapStateToProps, mapDispatchToProps)(Cart);


my saga for fetchCart:



 import call, put, takeLatest from 'redux-saga/effects';
import FETCH_CART from '../../constants/cart';
import fetchedCartSuccessful, fetchedCartError from
'../../actions/cart';
import axios from 'axios';

function* fetchCart()
try
const response = yield call([axios, axios.get], '/api/cart');

yield put(fetchedCartSuccessful(response.data));
catch (e)
yield put(fetchedCartError(e.response.data));



export function* watchFetchCart()
yield takeLatest(FETCH_CART, fetchCart);



and my saga for removeItem



 import call, put, takeLatest from 'redux-saga/effects';
import showAlert, rmAlert from '../../actions/alert';
import REMOVE_ITEM_IN_CART from '../../constants/cart';
import fetchCart from '../../actions/cart';
import axios from 'axios';

function* removeItemInCart(action)
yield put(rmAlert());

let alert = ;

try
const response = yield call([axios, axios.post], '/cart/remove-item',
productId: action.productId
);

alert.alertClass = 'alert-success';
alert.msg = response.data.success.msg;

yield put(fetchCart());
yield put(showAlert(alert));
catch (e)
alert.alertClass = 'alert-info';
alert.msg = e.response.data.error.msg;

yield put(showAlert(alert));



export function* watchRemoveItemInCart()
yield takeLatest(REMOVE_ITEM_IN_CART, removeItemInCart)



On my back end where I grab the cart from mysql database and send it back in a response. I console.log('executing') to make sure it is executing and no console.log is shown in the console? I have no idea whats going on. Again this works as expected on chrome and Firefox.



 app.get('/api/cart', (req, res) => 
const userId = req.signedCookies['user_cookie'];
console.log('executing'); //no console log saying this executed ?

const sql = `SELECT *, cart.quantity * products.price as price
FROM cart
LEFT JOIN products ON products.product_id = cart.product_id
WHERE user_id='$userId'`;

connection.query(sql, (err, result, fields) =>
if (err)
return res.status(500).json(
error:
msg: 'Something went wrong, couldn't GET cart'

);


let cart = quantity: 0, total: 0, items: ;

result.map(item =>
cart.quantity += item.quantity;
cart.total += item.price;
cart.items.push(item);
);
console.log(cart);
res.setHeader('content-type', 'text/javascript');
res.send(cart);
);
);


how do I check how many items should be in my cart? I do that below by visiting this route



 app.get('/all-carts', (req, res) => 
console.log(req.signedCookies['user_cookie'])
const sql = `SELECT * FROM cart`;

connection.query(sql, (err, results, feilds) =>
console.log(results);
res.setHeader('content-type', 'text/javascript');
res.send(results);
);
);


I visit that route and I get a response with an array of 4 items as expected cause I deleted 1. If I delete all the items I see an empty array. Yet when I view cart page I see 5 items being displayed still?



UPDATE -- when I clear browser history it shows the correct amount of items in the cart why do I have to clear browser history to see any updates on IE?










share|improve this question















Hi I am building a shopping cart and ran into problems on IE.(note everything works as expected on other browsers).



So my problem is for ex:
I have 5 items in a cart I click remove item on 1 item.
I refresh the page and that item is still there.
When I check my database for that item it doesn't exists anymore so it was deleted. So why am I still seeing that item that was deleted on the page?
This only happens in IE.



my component looks like this



class Cart extends Component 
componentDidMount()
console.log('executed') //I get executed in the console so that works.
this.props.fetchCart();


removeItem(productId)
this.props.dispatch(removeItem(productId));


render()
return (
<ul className='list-item'>

cart.items.map((item, index) =>
return (
<li className='list-group-item d-flex justify-content-between align-items-center' key=index>
<img style= width: '150px', height: '100px' src=item.main_img />
<h5>item.title</h5>
<small>quantity item.quantity</small>
<small>Price $item.price</small>
<button
onClick=() => this.removeItem(item.product_id)>Remove</button>
</li>
)
)

</ul>
)



const mapStateToProps = (state) =>
console.log(state.cart) //Always get 5 items instead of 4 which I should get 4 cause I deleted 1
return
cart: state.cart



const mapDispatchToProps = (dispatch) =>
return bindActionCreators( dispatch, rmAlert , dispatch);


export default connect(mapStateToProps, mapDispatchToProps)(Cart);


my saga for fetchCart:



 import call, put, takeLatest from 'redux-saga/effects';
import FETCH_CART from '../../constants/cart';
import fetchedCartSuccessful, fetchedCartError from
'../../actions/cart';
import axios from 'axios';

function* fetchCart()
try
const response = yield call([axios, axios.get], '/api/cart');

yield put(fetchedCartSuccessful(response.data));
catch (e)
yield put(fetchedCartError(e.response.data));



export function* watchFetchCart()
yield takeLatest(FETCH_CART, fetchCart);



and my saga for removeItem



 import call, put, takeLatest from 'redux-saga/effects';
import showAlert, rmAlert from '../../actions/alert';
import REMOVE_ITEM_IN_CART from '../../constants/cart';
import fetchCart from '../../actions/cart';
import axios from 'axios';

function* removeItemInCart(action)
yield put(rmAlert());

let alert = ;

try
const response = yield call([axios, axios.post], '/cart/remove-item',
productId: action.productId
);

alert.alertClass = 'alert-success';
alert.msg = response.data.success.msg;

yield put(fetchCart());
yield put(showAlert(alert));
catch (e)
alert.alertClass = 'alert-info';
alert.msg = e.response.data.error.msg;

yield put(showAlert(alert));



export function* watchRemoveItemInCart()
yield takeLatest(REMOVE_ITEM_IN_CART, removeItemInCart)



On my back end where I grab the cart from mysql database and send it back in a response. I console.log('executing') to make sure it is executing and no console.log is shown in the console? I have no idea whats going on. Again this works as expected on chrome and Firefox.



 app.get('/api/cart', (req, res) => 
const userId = req.signedCookies['user_cookie'];
console.log('executing'); //no console log saying this executed ?

const sql = `SELECT *, cart.quantity * products.price as price
FROM cart
LEFT JOIN products ON products.product_id = cart.product_id
WHERE user_id='$userId'`;

connection.query(sql, (err, result, fields) =>
if (err)
return res.status(500).json(
error:
msg: 'Something went wrong, couldn't GET cart'

);


let cart = quantity: 0, total: 0, items: ;

result.map(item =>
cart.quantity += item.quantity;
cart.total += item.price;
cart.items.push(item);
);
console.log(cart);
res.setHeader('content-type', 'text/javascript');
res.send(cart);
);
);


how do I check how many items should be in my cart? I do that below by visiting this route



 app.get('/all-carts', (req, res) => 
console.log(req.signedCookies['user_cookie'])
const sql = `SELECT * FROM cart`;

connection.query(sql, (err, results, feilds) =>
console.log(results);
res.setHeader('content-type', 'text/javascript');
res.send(results);
);
);


I visit that route and I get a response with an array of 4 items as expected cause I deleted 1. If I delete all the items I see an empty array. Yet when I view cart page I see 5 items being displayed still?



UPDATE -- when I clear browser history it shows the correct amount of items in the cart why do I have to clear browser history to see any updates on IE?







node.js reactjs internet-explorer react-redux






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 9 at 21:31

























asked Nov 9 at 20:39









radlaz

818




818











  • What does removeItem() and fetchCart() does in your code? Please share that too
    – Hemadri Dasari
    Nov 9 at 20:52











  • ok give me a min
    – radlaz
    Nov 9 at 20:54










  • I added my sagas that deal with that. On the backend for remove Item I do a MySQL delete statement I delete the row which columns product_id=the_product_id and user_id=the_user_id,
    – radlaz
    Nov 9 at 21:03

















  • What does removeItem() and fetchCart() does in your code? Please share that too
    – Hemadri Dasari
    Nov 9 at 20:52











  • ok give me a min
    – radlaz
    Nov 9 at 20:54










  • I added my sagas that deal with that. On the backend for remove Item I do a MySQL delete statement I delete the row which columns product_id=the_product_id and user_id=the_user_id,
    – radlaz
    Nov 9 at 21:03
















What does removeItem() and fetchCart() does in your code? Please share that too
– Hemadri Dasari
Nov 9 at 20:52





What does removeItem() and fetchCart() does in your code? Please share that too
– Hemadri Dasari
Nov 9 at 20:52













ok give me a min
– radlaz
Nov 9 at 20:54




ok give me a min
– radlaz
Nov 9 at 20:54












I added my sagas that deal with that. On the backend for remove Item I do a MySQL delete statement I delete the row which columns product_id=the_product_id and user_id=the_user_id,
– radlaz
Nov 9 at 21:03





I added my sagas that deal with that. On the backend for remove Item I do a MySQL delete statement I delete the row which columns product_id=the_product_id and user_id=the_user_id,
– radlaz
Nov 9 at 21:03













1 Answer
1






active

oldest

votes

















up vote
0
down vote













Try adding header 'pragma': 'no-cache' or 'Cache-Control': 'no-cache' to your axios get request call






share|improve this answer




















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53232959%2fstill-showing-old-data-that-doesnt-exist-on-page-using-ie%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    Try adding header 'pragma': 'no-cache' or 'Cache-Control': 'no-cache' to your axios get request call






    share|improve this answer
























      up vote
      0
      down vote













      Try adding header 'pragma': 'no-cache' or 'Cache-Control': 'no-cache' to your axios get request call






      share|improve this answer






















        up vote
        0
        down vote










        up vote
        0
        down vote









        Try adding header 'pragma': 'no-cache' or 'Cache-Control': 'no-cache' to your axios get request call






        share|improve this answer












        Try adding header 'pragma': 'no-cache' or 'Cache-Control': 'no-cache' to your axios get request call







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 10 at 15:23









        Prerna Chuttani

        1




        1



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53232959%2fstill-showing-old-data-that-doesnt-exist-on-page-using-ie%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Darth Vader #20

            How to how show current date and time by default on contact form 7 in WordPress without taking input from user in datetimepicker

            Ondo