Hello,
I recently started using ADF, I'm building an app using my instalation of Alfresco ECM 5.2, I have created a page within the app using the tutorials provided here.
My problem is that, i want to display information about a site which is on my ECM platform, i can login succesfully to platform but when it comes to getting the site info i have this error:
and this is my component.ts:
The weird part is that, i try the query on postman and it gives me the site i'm looking for:
I will appreciate any kind of help in this matter,
Thanks in advance,
Solved! Go to Solution.
You already import 'AlfrescoApiService' that reduces the code, you may also want to use 'AlfrescoAuthenticationService' to perform the login.
Here's the snippet code for the component that works for me and retrieves the site data, I've created a new public site 'demo1':
You are losing the context of "this" when calling "promise.then(..)" with a "function" parameter. Try using the "fat arrow" syntax to allow TypeScript maintaining the context for you:
getSite(...).then(data => {
if (data) {
this.nombreSitio = "your value";
}
});
Thanks, but now i have this:
as you see, it doesnt seem to catch the correct values.
Also i have these errors when i inspect the page, i dont know if they are related:
Based on your initial screenshot - your async code is executed in parallel. You try to log in and get data at the same time within different promises.
You should be calling Alfresco JS Api methods after login promise is resolved, for example:
api.login('admin', 'admin').then(ticket => {
sites.getSite(...).then(data => {
....
});
});
Based on your advice i modified my component.ts, now its like this:
but it still not catching the correct values:
thanks
You already import 'AlfrescoApiService' that reduces the code, you may also want to use 'AlfrescoAuthenticationService' to perform the login.
Here's the snippet code for the component that works for me and retrieves the site data, I've created a new public site 'demo1':
Please note that the JSON payload that comes with the JS API call is wrapped into the "entry":
{"entry":{"role":"SiteManager","visibility":"PUBLIC","guid":"08918280-26ba-4e9a-a2a7-a31075184144","id":"demo1","title":"demo1"}}
So you might need binding your properties to the "data.entry.id"
It worked, thanks a lot
Discussions, help and advice about the Alfresco Development Framework.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.