ilink-world/webservice/AuthKeyApi.js

25 lines
934 B
JavaScript

import axios from "axios";
import { authKeyUrl, authKeyData } from "./IlinkConstants";
import { fetchAuthKeySuccess, fetchAuthKeyPending, fetchAuthKeyError } from "../redux/actions/AuthKeyActions";
const getAuthApiKey = (email) => {
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;