EU
Size: a a a
EU
VZ
DM
export function api(method, obj, callback) {
console.info("New api request:", "/api/"+method);
return (dispatch) => {
console.info("New api request:", "/api/"+method);
...VZ
EU
EU
VZ
EU
EU
EU
VZ
EU
EU
EU
export function api(method, obj, callback) {
console.info("New api request:", "/api/"+method);
return (dispatch) => {
dispatch({
type: API_REQUEST
})
obj.token = store.getState().App.token;
axios({
method: 'post',
headers: {'Content-Type': 'application/json;charset=utf-8'},
url: 'http://localhost:4000/api/' + method,
data: obj
}).then((res) => {
if(res.data.success) {
console.log(res.data);
dispatch({
type: API_REQUEST_SUCCESS
});
callback(res.data);
} else {
dispatch({
type: API_REQUEST_FAILTURE,
payload: {
error: res.data.err
}
});
}
}).catch((err) => {
if(err.message == "Network Error") err = "Ошибка соединения";
dispatch({
type: API_REQUEST_FAILTURE,
payload: {
error: err.toString()
}
});
});
};
}VZ
EU
EU
VZ
VZ