Initial commit
This commit is contained in:
33
Source/interface/Actions.js
Normal file
33
Source/interface/Actions.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import dispatcher from "../dispatcher";
|
||||
import api from "axios";
|
||||
|
||||
var jsonReq = {
|
||||
action: "?",
|
||||
filters: []
|
||||
};
|
||||
|
||||
export function logout() {
|
||||
dispatcher.dispatch({ type: 'LOGOUT', data: { auth: 0, msg: 'logged out', token: '' } });
|
||||
}
|
||||
|
||||
export function apiCall(route, action, filters) {
|
||||
jsonReq.action = action;
|
||||
jsonReq.filters = filters;
|
||||
api.post('/api/' + route, jsonReq)
|
||||
.then(function (resp) {
|
||||
dispatcher.dispatch({
|
||||
type: action,
|
||||
data: resp.data
|
||||
});
|
||||
})
|
||||
.catch(function (error) {
|
||||
dispatcher.dispatch({
|
||||
type: "API_ERR",
|
||||
data: error
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function localCall(action, data) {
|
||||
dispatcher.dispatch({ type: action, data: data });
|
||||
}
|
||||
Reference in New Issue
Block a user