-
-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Portals Web API #156
Conversation
Hi @03-CiprianoG ! A question for you, because I haven't worked with Portals much and don't know this information: is it possible to make it work without introducing a new config property? I was thinking that maybe if Portals have some kind of global JavaScript object that could be checked and if it exists instantly realize that the code is running there. Like, something similar to If yes, we could just add a code to check for What do you think? P.S. Thank you for the kind words! 😃 |
Hi @AleksandrRogov 🫡. The global object you kind of mentioned definitely exists and is I'm happy with the result and I'm currently using it rn :), Thank you for your time again. |
Awesome! Well done! I've also checked Portals documentation and found out that a token is needed to access the api. Like in this example: //Web API ajax wrapper
(function(webapi, $) {
function safeAjax(ajaxOptions) {
var deferredAjax = $.Deferred();
shell.getTokenDeferred().done(function(token) {
// 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) Do you have an example on how to do that with DynamicsWebApi so I could add it to the documentation? Thanks! I will merge this later (also add some tests) and I also wanted to add another feature, so I will release both of them at the same time. Thanks again for your help! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Need to make sure that the node.js app does not break because of the
window
object. - Maybe move the conditions around so the parts that aren't used in Node.js can be removed by tree shaking.
- Make sure the bundling process is working fine.
- Add tests.
Hey Aleksandr,
Firstly I wanted to say thank you, I really appreciate your work :)
This minor patch aims to add support to the portals Web API.
Since I'm myself using a patched version of this library, I thought I could add those few lines of code and make a minor version out of it..
As far as I know the Portals Web API uses another URL but the same protocol, so we shouldn't need additional test/types for this "feature".
Let me know what you think and keep the amazing work up :)