Advertisement
gpressutto5

Untitled

Jul 22nd, 2017
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let updatePrices = () => {
  2.     console.log(getExchangeRates());
  3. };
  4.  
  5. let getExchangeRates = () => {
  6.     let localstorage_name = currentCurrency;
  7.     if (localstorage.get(localstorage_name)) {
  8.         return localstorage.get(localstorage_name);
  9.     }
  10.     $.ajax({
  11.         url: phpvars.ajaxurl,
  12.         type: 'GET',
  13.         data: {
  14.             action: 'get_exchange_rate',
  15.             currency: currentCurrency,
  16.         }
  17.     }).done((data) => {
  18.         data = JSON.parse(data);
  19.         if (data.status !== 'SUCCESS') {
  20.             console.log('error');
  21.             return;
  22.         }
  23.  
  24.         localstorage.set(localstorage_name, data, timeToExpire);
  25.         return localstorage.get(localstorage_name);
  26.     });
  27. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement