update proxy for get - update appeal record data

This commit is contained in:
robert.bond@test.gov.wales
2021-09-15 16:43:17 +01:00
parent 2c4638f319
commit 6ad60b990b
4 changed files with 161 additions and 46 deletions
+17 -3
View File
@@ -72,6 +72,20 @@ export default async function ApiProxy(req, res) {
// console.log(SASToken);
var configNoData = {
method: req.method,
//url: WEBAPI_URL + updateFormCollection + "(" + incidentId + ")",
url: WEBAPI_URL + req.url.split("/api/proxy/")[1],
headers: {
"OData-MaxVersion": "4.0",
"OData-Version": "4.0",
"Accept": "application/json",
"Prefer": 'odata.include-annotations="*",return=representation',
"Authorization": SASToken,
"Content-Type": "application/json",
},
};
var config = {
method: req.method,
//url: WEBAPI_URL + updateFormCollection + "(" + incidentId + ")",
@@ -87,17 +101,17 @@ export default async function ApiProxy(req, res) {
data: data,
};
console.log(config);
console.log(req.url.split("/api/proxy/")[1]);
return new Promise((resolve, reject) => {
// console.log(config);
axios(config)
axios(req.method == "GET" ? configNoData : config)
.then((response) => {
res.statusCode = 200;
res.setHeader("Content-Type", "application/json");
res.setHeader("Cache-Control", "max-age=1800000");
res.end(JSON.stringify(response.data));
console.log("response data", response.data);
// console.log("response data", response.data);
resolve();
})
.catch((error) => {