title: Getting access token with the refresh token after expiration(JWT)
body: <p>I get 401 error after a while when the page is reloaded, I figured it could be because the access token is expired. How do I set a new token with my refresh token? The below function runs every time the user visits a new page or refreshes the page. But it doesn't seem to work.</p>
  <pre><code>export async function currentAccount() {
  
  
    if (store.get('refreshToken')) {
      const query = {
        grant_type: 'refresh_token',
        companyId: store.get('lastCompanyId'),
        refresh_token: store.get('refreshToken'),
      }
      const queryString = new URLSearchParams(query).toString()
      const actionUrl = `${REACT_APP_SERVER_URL}/login?${queryString}`
      return apiClient
        .post(actionUrl, { auth: 'basic' })
        .then(async response =&gt; {
          if (response) {
            const { access_token: accessToken } = response.data
              store.set('accessToken', accessToken)
            return response.data
          }
          return false
        })
        .catch(err =&gt; {
          console.log('error', err)
          store.clearAll()
        })
    }
    return false
  }
  </code></pre>
  <p><strong>Login sets the access tokens</strong></p>
  <pre><code>export async function login(email, password) {
    const query = {
      grant_type: 'password',
      username: email,
      password,
    }
    const queryString = new URLSearchParams(query).toString()
    const actionUrl = `${REACT_APP_SERVER_URL}/login?${queryString}`
    return apiClient
      .post(actionUrl, { auth: 'basic' })
      .then(async response =&gt; {
        if (response) {
          const {
            data: {
              access_token: accessToken,
              refresh_token: refreshToken,
            },
          } = response
          const decoded = jsonwebtoken.decode(accessToken)
          response.data.authUser = decoded.authUser
          const { userId, profileId, companyId } = decoded.authUser
          if (accessToken) {
            store.set('accessToken', accessToken)
            store.set('refreshToken', refreshToken)
          }
          return response.data
        }
        return false
      })
      .catch(err =&gt; console.log(err))
  }
  </code></pre>
  <p><strong>saga users.js</strong></p>
  <pre><code>export function* LOAD_CURRENT_ACCOUNT() {
    yield put({
      type: 'user/SET_STATE',
      payload: {
        loading: true,
      },
    })
    const { authProvider } = yield select((state) =&gt; state.settings)
    const response = yield call(mapAuthProviders[authProvider].currentAccount)
    if (response) {
      const decoded = jsonwebtoken.decode(response.access_token)
      response.authUser = decoded.authUser
      yield store.set('id', id)
      try {
        const user = yield call(LoadUserProfile)
        if (user) {
          const { company } = user
          yield put({
            type: 'user/SET_STATE',
            payload: {
              ...user,
              preferredDateFormat: user.preferredDateFormat || 'DD/MM/YYYY',
              userId,
              id,
            },
          })
        }
      } catch (error) {
      }
    }else{
      store.set('refreshToken', response.refreshToken)
    }
  
    yield put({
      type: 'user/SET_STATE',
      payload: {
        loading: false,
      },
    })
  }
  </code></pre>