updated coords and address fix

This commit is contained in:
2025-03-14 15:20:06 +00:00
parent 9eace1b626
commit 68d03ed93d
15 changed files with 347 additions and 727 deletions
+36 -10
View File
@@ -27,17 +27,43 @@ export default async function ApiProxy(req, res) {
"pinswg_dnses?$select=pinswg_name,pinswg_anticipatedgridreferenceeastingtext,pinswg_anticipatedgridreferencenorthingtext,pinswg_projectname,pinswg_dnsid,_pinswg_associatedlpa_value,_pinswg_appellant_value&$filter=pinswg_anticipatedgridreferencenorthingtext ne null and pinswg_anticipatedgridreferenceeastingtext ne null&$count=true";
//console.log("dns ", queryUrl);
var queryUrlSips =
"pinswg_sipses?$select=pinswg_name,pinswg_anticipatedgridrefeasting,pinswg_anticipatedgridrefnorthing,pinswg_projectname,pinswg_sipscase,_pinswg_associatedlpa_value,_pinswg_appellant_value&$filter=pinswg_anticipatedgridrefeasting ne null and pinswg_anticipatedgridrefnorthing ne null&$count=true";
return axios
.get(
var coordsObj = { value: [] };
try {
// First Axios request
const dnsCoordsObj = await axios.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeaders(token.access_token)
)
.then(({ data }) => {
res.status(200).json(data);
})
.catch((error) => {
consoleLogger(error);
res.status(400).json(error);
});
);
// Merge the first response's 'value' array into the coordsObj's value array
if (Array.isArray(dnsCoordsObj.data.value)) {
coordsObj.value = coordsObj.value.concat(dnsCoordsObj.data.value); // Concatenate arrays
} else if (dnsCoordsObj.data.value) {
coordsObj.value.push(dnsCoordsObj.data.value); // Push single value if it's not an array
}
// Second Axios request
const sipsCoordsObj = await axios.get(
WEBAPI_URL + queryUrlSips + hashAPIPath(queryUrlSips),
azureHeaders(token.access_token)
);
// Merge the second response's 'value' array into the coordsObj's value array
if (Array.isArray(sipsCoordsObj.data.value)) {
coordsObj.value = coordsObj.value.concat(sipsCoordsObj.data.value); // Concatenate arrays
} else if (sipsCoordsObj.data.value) {
coordsObj.value.push(sipsCoordsObj.data.value); // Push single value if it's not an array
}
Object.assign(coordsObj, { "@odata.count": coordsObj.value.length });
// Send the merged values as the response
return res.status(200).json(coordsObj);
} catch (error) {
// Catch any errors and send an error response
consoleLogger(error);
return res.status(400).json(error);
}
}