remove references to token
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import axios from "axios";
|
||||
import https from "https";
|
||||
import CryptoJS from "crypto-js";
|
||||
import _ from "lodash";
|
||||
import { getToken, azureHeadersPaged } from "../../../actions";
|
||||
|
||||
const WORDKEY = process.env.HASHKEY;
|
||||
|
||||
const WEBAPI_URL =
|
||||
@@ -24,12 +26,14 @@ export default async function ApiProxy(req, res) {
|
||||
var searchString = req.query.searchstring;
|
||||
var token = await getToken();
|
||||
|
||||
searchString = JSON.parse(searchString);
|
||||
searchString = _.isEmpty(searchString)
|
||||
? searchString
|
||||
: JSON.parse(decodeURI(searchString));
|
||||
|
||||
var queryString = "";
|
||||
|
||||
queryString +=
|
||||
searchString.q != null
|
||||
_.has(searchString, "q") && searchString.q != null
|
||||
? "(contains(title, '" +
|
||||
searchString.q +
|
||||
"') or contains(ticketnumber,'" +
|
||||
@@ -38,13 +42,13 @@ export default async function ApiProxy(req, res) {
|
||||
: "";
|
||||
|
||||
queryString +=
|
||||
searchString.lpa != null
|
||||
_.has(searchString, "lpa") && searchString.lpa != null
|
||||
? (typeof searchString.q == "undefined" ? "" : " and ") +
|
||||
"_pinswg_associatedlpa_value eq " +
|
||||
searchString.lpa
|
||||
: "";
|
||||
queryString +=
|
||||
searchString.apt != null
|
||||
_.has(searchString, "apt") && searchString.apt != null
|
||||
? (typeof searchString.q == "undefined" &&
|
||||
typeof searchString.lpa == "undefined"
|
||||
? ""
|
||||
@@ -58,15 +62,23 @@ export default async function ApiProxy(req, res) {
|
||||
queryString +
|
||||
" and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true";
|
||||
|
||||
return axios
|
||||
.get(
|
||||
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
|
||||
azureHeadersPaged(token.access_token)
|
||||
)
|
||||
.then(({ data }) => {
|
||||
res.status(200).json(data);
|
||||
})
|
||||
.catch(({ err }) => {
|
||||
res.status(400).json(err);
|
||||
});
|
||||
var apiResponse = _.isEmpty(searchString)
|
||||
? res.status(400).json()
|
||||
: axios
|
||||
.get(
|
||||
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
|
||||
azureHeadersPaged(token.access_token)
|
||||
)
|
||||
.then(({ data }) => {
|
||||
var dataStr;
|
||||
_.has(data, "@odata.nextLink") == true &&
|
||||
((dataStr = JSON.stringify(data["@odata.nextLink"])),
|
||||
(data["@odata.nextLink"] = dataStr.split("/v8.2/")[1]));
|
||||
res.status(200).json(data);
|
||||
})
|
||||
.catch(({ err }) => {
|
||||
res.status(400).json(err);
|
||||
});
|
||||
|
||||
return apiResponse;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user