fix(dm): missing api key call, and better logging on the post orders section
This commit is contained in:
@@ -14,7 +14,8 @@ export const postForecast = async (data: any, user: any) => {
|
||||
url: endpoint,
|
||||
method: "POST",
|
||||
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
|
||||
data: data,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import axios from "axios";
|
||||
import { prodEndpointCreation } from "../../../../../globalUtils/createUrl.js";
|
||||
import { createLog } from "../../../../logger/logger.js";
|
||||
|
||||
export const postOrders = async (data: any, user: any) => {
|
||||
let endpoint = await prodEndpointCreation(
|
||||
@@ -11,7 +12,8 @@ export const postOrders = async (data: any, user: any) => {
|
||||
url: endpoint,
|
||||
method: "POST",
|
||||
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
|
||||
data: data,
|
||||
@@ -19,6 +21,12 @@ export const postOrders = async (data: any, user: any) => {
|
||||
|
||||
//console.log(results.status);
|
||||
if (results.data.errors) {
|
||||
createLog(
|
||||
"error",
|
||||
user.username,
|
||||
"logisitcs",
|
||||
results.data.errors[0].message
|
||||
);
|
||||
return {
|
||||
success: true,
|
||||
message: "Error processing orders",
|
||||
@@ -27,6 +35,12 @@ export const postOrders = async (data: any, user: any) => {
|
||||
}
|
||||
|
||||
if (results.status === 200) {
|
||||
createLog(
|
||||
"info",
|
||||
user.username,
|
||||
"logisitcs",
|
||||
"Orders were processed please check 2.0 for validation and errors"
|
||||
);
|
||||
return {
|
||||
success: true,
|
||||
message: "Success on posting orders",
|
||||
@@ -37,6 +51,7 @@ export const postOrders = async (data: any, user: any) => {
|
||||
//console.log(`There is an error`, error);
|
||||
if (error) {
|
||||
//console.log(error.response.data);
|
||||
createLog("error", user.username, "logisitcs", error.response.data);
|
||||
return {
|
||||
success: false,
|
||||
message: "There was an error processing data",
|
||||
|
||||
Reference in New Issue
Block a user