mirror of
https://github.com/roleypoly/roleypoly-v1.git
synced 2025-06-16 18:29:08 +00:00
finish most of redux retrofit
This commit is contained in:
parent
52cb96baa3
commit
5899268b22
7 changed files with 64 additions and 17 deletions
|
@ -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)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue