import request from 'superagent'

module.exports = (dispatch, flopInfo) => {
  console.log(flopInfo);
  request
    .post('https://topoftheflops.herokuapp.com/api/v1/flops')
    .send(flopInfo)
    .withCredentials()
    .end((err, res) => {
      if (err) return console.log(err)
      console.log(res.body.error);
      if (res.body.error) {
        dispatch({type: 'CHANGE_PAGE', payload: '/unauthenticated'})
      }
      else dispatch({type: 'CHANGE_PAGE', payload: '/flops'})
    })
}

import request from 'superagent'
import getFlops from '../api/getFlops'

module.exports = (dispatch, flopInfo) => {
  console.log(flopInfo);
  request
    .post('https://topoftheflops.herokuapp.com/api/v1/flops')
    .send(flopInfo)
    .withCredentials()
    .end((err, res) => {
      if (err) return console.log(err)
      // console.log(res.body.error);
      if (res.body.error) {
        dispatch({type: 'CHANGE_PAGE', payload: '/unauthenticated'})
      }
      else {
        getFlops(dispatch)
        dispatch({type: 'CHANGE_PAGE', payload: '/flops'})
      }
    })
}

Create a new flop works with the db
Create a new flop works with the db
