This commit is contained in:
2020-09-08 20:34:41 +00:00
parent 1ac6fc68a7
commit 0a385a8361
2 changed files with 48 additions and 4 deletions

View File

@@ -86,13 +86,55 @@ async function ayPrepareData(reportData) {
//before the report is rendered
//modify data as required here and return it to change the data before the report renders
//Example of using API method to fetch data from API server and make it available to the report template
let route=`${reportData.ayServerMetaData.ayApiUrl}enum-list/list/AyaType`;
//Example of using API GET method to fetch data from API server and make it available to the report template
let route=`${reportData.ayServerMetaData.ayApiUrl}server-info`;
//Put the data into the main report data object so it's available to the template
reportData.myData={AyaTypeList:await ayGetFromAPI(route, reportData.ayClientMetaData.Authorization)};
reportData.myData={ServerInfo:await ayGetFromAPI(route, reportData.ayClientMetaData.Authorization)};
//Example API POST method to fetch data from api server
route=`${reportData.ayServerMetaData.ayApiUrl}search`;
let searchPostData={phrase: "Fish"};
reportData.myData.SearchResults=await ayPostToAPI(route, reportData.ayClientMetaData.Authorization,searchPostData);
return reportData;
}
<html>
<body>
<div>
<h4>ayServerMetaData</h4>
{{ ayJSON ayServerMetaData }}
</div>
<div>
<h4>ayClientMetaData</h4>
{{ ayJSON ayClientMetaData }}
</div>
<div>
<h4>ayReportMetaData</h4>
{{ ayJSON ayReportMetaData }}
</div>
<div>
<h4>myData</h4>
<h5>(Fetched dynamically from API route <strong>enum-list/list/AyaType</strong>)</h5>
{{ ayJSON myData }}
</div>
<div>
<h4>ayReportData</h4>
{{#each ayReportData}}
<h2>{{ Name }}</h2>
<div>Notes: <span class="example">{{ Notes }}</span></div>
{{/each}}
</div>
</body>
</html>
*/