Compare commits

..

2 Commits

3 changed files with 19 additions and 3 deletions

View File

@@ -36,7 +36,7 @@
} }
}, },
"admConfig": { "admConfig": {
"build": 469, "build": 470,
"oldBuild": "backend-0.1.3.zip" "oldBuild": "backend-0.1.3.zip"
}, },
"devDependencies": { "devDependencies": {

View File

@@ -14,7 +14,8 @@ export const postForecast = async (data: any, user: any) => {
url: endpoint, url: endpoint,
method: "POST", method: "POST",
headers: { headers: {
Authorization: `Basic ${user.prod}`, "X-API-Key": process.env.TEC_API_KEY || "",
"Content-Type": "application/json",
}, },
// if a body is sent over it would be like below // if a body is sent over it would be like below
data: data, data: data,

View File

@@ -1,5 +1,6 @@
import axios from "axios"; import axios from "axios";
import { prodEndpointCreation } from "../../../../../globalUtils/createUrl.js"; import { prodEndpointCreation } from "../../../../../globalUtils/createUrl.js";
import { createLog } from "../../../../logger/logger.js";
export const postOrders = async (data: any, user: any) => { export const postOrders = async (data: any, user: any) => {
let endpoint = await prodEndpointCreation( let endpoint = await prodEndpointCreation(
@@ -11,7 +12,8 @@ export const postOrders = async (data: any, user: any) => {
url: endpoint, url: endpoint,
method: "POST", method: "POST",
headers: { headers: {
Authorization: `Basic ${user.prod}`, "X-API-Key": process.env.TEC_API_KEY || "",
"Content-Type": "application/json",
}, },
// if a body is sent over it would be like below // if a body is sent over it would be like below
data: data, data: data,
@@ -19,6 +21,12 @@ export const postOrders = async (data: any, user: any) => {
//console.log(results.status); //console.log(results.status);
if (results.data.errors) { if (results.data.errors) {
createLog(
"error",
user.username,
"logisitcs",
results.data.errors[0].message
);
return { return {
success: true, success: true,
message: "Error processing orders", message: "Error processing orders",
@@ -27,6 +35,12 @@ export const postOrders = async (data: any, user: any) => {
} }
if (results.status === 200) { if (results.status === 200) {
createLog(
"info",
user.username,
"logisitcs",
"Orders were processed please check 2.0 for validation and errors"
);
return { return {
success: true, success: true,
message: "Success on posting orders", message: "Success on posting orders",
@@ -37,6 +51,7 @@ export const postOrders = async (data: any, user: any) => {
//console.log(`There is an error`, error); //console.log(`There is an error`, error);
if (error) { if (error) {
//console.log(error.response.data); //console.log(error.response.data);
createLog("error", user.username, "logisitcs", error.response.data);
return { return {
success: false, success: false,
message: "There was an error processing data", message: "There was an error processing data",