improved error loggin and updated imports to fix build failure

This commit is contained in:
2024-06-19 15:06:28 +01:00
parent d01179c724
commit be99db0774
78 changed files with 319 additions and 325 deletions
+31 -19
View File
@@ -39,31 +39,43 @@ const hashAPIPath = (queryPath) => {
export default async function ApiProxy(req, res) {
var emailAddress = req.query.emailAddress;
var token = await getToken();
var checkHash = req.query.hash;
var checkquerypath =
"/api/endpoint/getportallogin_api?emailAddress=" + emailAddress;
// console.log("-----", casefolderID);
// console.log("-----", req.query);
// console.log("-----", checkquerypath);
// console.log("-----", hashAPIPath(checkquerypath));
// console.log("-----", checkHash);
// console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash);
var queryUrl =
"contacts?$filter=emailaddress1 eq '" +
emailAddress +
"' and statuscode eq 1&$count=true&$select=emailaddress1,contactid,yomifullname,firstname,lastname";
console.log(req.query, queryUrl);
var apiResponse = _.isEmpty(req.query)
? res.status(400).json()
: typeof emailAddress != "undefined" && emailAddress.length > 0
? axios
.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeadersPaged(token.access_token)
)
.then(({ data }) => {
//console.log(data);
res.status(200).json(data);
})
.catch((err) => {
console.log(consoleLogger(err));
res.status(400).json(err);
})
: res.status(400).json();
if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
var apiResponse = _.isEmpty(req.query)
? res.status(400).json()
: typeof emailAddress != "undefined" && emailAddress.length > 0
? axios
.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeadersPaged(token.access_token)
)
.then(({ data }) => {
//console.log(data);
res.status(200).json(data);
})
.catch((error) => {
consoleLogger(error);
res.status(400).json(error);
})
: res.status(400).json();
} else {
return res.status(400).json();
}
return apiResponse;
}