32 lines
883 B
JavaScript
32 lines
883 B
JavaScript
import axios from "axios";
|
|
import { applicationConfig } from "@/constants/applicationConfig.js";
|
|
import httpStatusCodes from "http-status-codes";
|
|
|
|
export default {
|
|
callHttpClient({ method, endpoint, payload}) {
|
|
return new Promise((resolve, reject) => {
|
|
|
|
const apiGatewayUrl = applicationConfig.CONSUMER_APIGATEWAY_URL;
|
|
const payloadAndAnalyticsData = Object.assign({}, payload, {AppName: "FixMyGlass"});
|
|
|
|
axios({
|
|
method: method,
|
|
url: `${apiGatewayUrl}${endpoint}`,
|
|
data: payloadAndAnalyticsData,
|
|
crossDomain: true,
|
|
responseType: {},
|
|
}).then((response) => {
|
|
|
|
if (response.status == httpStatusCodes.OK) {
|
|
resolve(response);
|
|
} else {
|
|
reject(response);
|
|
}
|
|
},
|
|
(error) => {
|
|
return reject(error.response);
|
|
}
|
|
);
|
|
});
|
|
},
|
|
};
|