2020-04-18 19:59:05 +00:00
|
|
|
import axios from "axios";
|
|
|
|
import { authKeyUrl, authKeyData } from "./IlinkConstants";
|
|
|
|
import { fetchAuthKeySuccess, fetchAuthKeyPending, fetchAuthKeyError } from "../redux/actions/AuthKeyActions";
|
|
|
|
|
2020-04-20 10:43:01 +00:00
|
|
|
const getAuthApiKey = (phone) => {
|
|
|
|
|
|
|
|
const data = authKeyData;
|
|
|
|
authKeyData.username = phone;
|
|
|
|
authKeyData.password = "";
|
|
|
|
|
2020-04-18 19:59:05 +00:00
|
|
|
return dispatch => {
|
|
|
|
dispatch(fetchAuthKeyPending());
|
|
|
|
axios.post(authKeyUrl, authKeyData)
|
|
|
|
.then(response => {
|
|
|
|
dispatch(fetchAuthKeySuccess(response));
|
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
dispatch(fetchAuthKeyError(error.message));
|
|
|
|
if (error.response)
|
|
|
|
dispatch(fetchAuthKeyError(error.response));
|
|
|
|
else if (error.request)
|
|
|
|
dispatch(fetchAuthKeyError(error.request))
|
|
|
|
else
|
|
|
|
dispatch(fetchAuthKeyError(error.message))
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default getAuthApiKey;
|