Optimize data handling by embedding EnvelopeResponse in Razor Page, eliminating additional requests

This commit is contained in:
Developer 02
2024-04-08 17:05:01 +02:00
parent 1584fd6f1c
commit 6941a3db8d
3 changed files with 19 additions and 24 deletions

View File

@@ -44,6 +44,7 @@
</div>
</div>
}
<script>
const collapseNav = () => {
document.addEventListener('click', function (event) {
@@ -57,8 +58,20 @@
});
}
@{
var envelopeResponse = ViewData["EnvelopeResponse"];
var settings = new Newtonsoft.Json.JsonSerializerSettings
{
ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver()
};
var envelopeResponseJson = Newtonsoft.Json.JsonConvert.SerializeObject(envelopeResponse, settings);
}
var envelopeResponse = @Html.Raw(envelopeResponseJson);
console.log(envelopeResponse);
document.addEventListener("DOMContentLoaded", async () => {
const app = new App("#app", "@ViewData["EnvelopeKey"]");
const app = new App("#app", "@ViewData["EnvelopeKey"]", envelopeResponse);
await app.init();
})
</script>