Files
pedwfrontend/pages/api/endpoint/getformdata_api.js
T

30 lines
866 B
JavaScript

import { respondError } from "../middleware/apiResponse";
import { relayGet } from "../middleware/relayForwarding";
export default async function ApiProxy(req, res) {
const whichForm = req.query.whichForm;
if (typeof whichForm !== "string" || whichForm.trim().length === 0) {
return respondError(res, {
status: 400,
code: "WHICH_FORM_REQUIRED",
message: "whichForm is required"
});
}
const queryUrl =
"systemforms?$select=formid,name,formxml,type,objecttypecode&$filter=(objecttypecode eq 'pinswg_" +
whichForm +
"' and type eq 2)&$count=true&$top=201";
return relayGet({
queryUrl,
res,
errorResponse: {
status: 400,
code: "FORM_DATA_FETCH_FAILED",
message: "Failed to fetch form data"
}
});
}