function currentUser() {
  return dispatch => {
    const token = localStorage.token
    const reqObj = {
      method: "GET",
      headers: {
        Authorization: `Bearer ${token}`
      }
    }
    return fetch("http://localhost:3000/api/v1/current_user", reqObj)
      .then(res => res.json())
      .then(data => {
        if (data.error) {
          console.log("currentUser error: ", data)
        } else {
          dispatch(loginUser(data.user))
        }
      })
      .catch(err => console.log(err))
  }
}
// ! Finds the current user using token
Finds the current user using token
Finds the current user using token
function currentUser() {
  return dispatch => {
    const token = localStorage.token
    const reqObj = {
      method: "GET",
      headers: {
        Authorization: `Bearer ${token}`
      }
    }
    return fetch("http://localhost:3000/api/v1/current_user", reqObj)
      .then(res => res.json())
      .then(data => {
        if (data.error) {
          console.log("currentUser error: ", data)
        } else {
          dispatch(loginUser(data.user))
        }
      })
      .catch(err => console.log(err))
  }
}
function currentUser ( ) { return dispatch => { const token = localStorage . token const reqObj = { method : "GET" , headers : { Authorization : ` ${ token } ` } } return fetch ( "http://localhost:3000/api/v1/current_user" , reqObj ) . then ( res => res . json ( ) ) . then ( data => { if ( data . error ) { console . log ( "currentUser error: " , data ) } else { dispatch ( loginUser ( data . user ) ) } } ) . catch ( err => console . log ( err ) ) } }
Finds the current user using token
Finds the current user using token