Hi,
We have developed the PCF control for Power Pages and integrated it onto the relevant pages. However, we now have a requirement from the customer that necessitates the utilization of the Power Pages Web API. Upon attempting to incorporate the code available at the link provided below, we encountered an issue.
We are encountering an issue with the code below.
(function (webapi, $) {
function safeAjax(ajaxOptions:any) {
var deferredAjax = $.Deferred();
shell.getTokenDeferred().done(function (token:any) {
// add headers for AJAX
if (!ajaxOptions.headers) {
$.extend(ajaxOptions, {
headers: {
"__RequestVerificationToken": token
}
});
} else {
ajaxOptions.headers["__RequestVerificationToken"] = token;
}
$.ajax(ajaxOptions)
.done(function (data, textStatus, jqXHR) {
validateLoginSession(data, textStatus, jqXHR, deferredAjax.resolve);
}).fail(deferredAjax.reject); //AJAX
}).fail(function () {
deferredAjax.rejectWith(this, arguments); // on token failure pass the token AJAX and args
});
return deferredAjax.promise();
}
webapi.safeAjax = safeAjax;
})(window.webapi = window.webapi || {}, jQuery)
Does anyone have sample code demonstrating how to utilize the Power Pages Web API within a PCF control.
Thanks!


Report
All responses (
Answers (