finish most of redux retrofit

This commit is contained in:
41666 2017-12-10 04:26:28 -06:00
parent 52cb96baa3
commit 5899268b22
7 changed files with 64 additions and 17 deletions

View file

@ -0,0 +1,25 @@
import superagent from 'superagent'
export const fetchServers = async dispatch => {
const rsp = await superagent.get('/api/servers')
dispatch({
type: Symbol.for('update servers'),
data: rsp.body
})
}
export const userInit = async dispatch => {
try {
const rsp = await superagent.get('/api/auth/user')
dispatch({
type: Symbol.for('set user'),
data: rsp.body
})
dispatch(fetchServers)
} catch(e) {
console.log(e)
}
}