Hi,
I am building my app using vue.
i am trying to use jdrupal as its seems very good but its showing undefined whenever i tried to console anything.
1) my drupal path is :: http://localhost/d8angular/drupal8/web/
2) vue running on local port
3) on cusotm js ::
i defined my site path but everything is undefined::
jDrupal.config('sitePath', 'http://localhost/d8angular/drupal8/web');
jDrupal.connect().then(function() {
var user = jDrupal.currentUser();
var msg = user.isAuthenticated() ?
'Hello ' + user.getAccountName() : 'Hello World';
console.log(user.getAccountName());
});
i checked header jdrupal.min script is there
i.e.
i am unable to find what's wrong it it as documentation says just include js & get the data?
can you help me out?
thanks
Comment | File | Size | Author |
---|---|---|---|
#3 | jd2.PNG | 38.26 KB | drupalprog |
#3 | jd1.PNG | 603.82 KB | drupalprog |
Comments
Comment #2
tyler.frankenstein CreditAttribution: tyler.frankenstein commentedI don't fully understand. Will you please clarify with your console statements and any other code?
Comment #3
drupalprog CreditAttribution: drupalprog commentedHi tyler,
thanks for replying.
sorry for the confusion
as i am saying whenever i tried to console user uid, role , username whatever
but its always console uid =0, role= anonymous.
I am logged in as admin on my drupal website on same browser but it always showing anonymous user.
i am attaching two screenshot that showing console of jdrupal(in vue) & drupal in which i logged in as admin but still showing anonymous user.
thanks
Comment #4
tyler.frankenstein CreditAttribution: tyler.frankenstein commentedYou're likely experiencing a CORS issue. For example, your Drupal site is running out of http://localhost/d8angular/drupal8/web and the app is running out of http://localhost:8080
These are two different domains, and browsers by default protect against this (cross origin resource sharing).
If you move your app to run out of http://localhost/d8angular/drupal8/web/app that should fix it, otherwise you'll have to configure your Drupal site and webserver for CORS.
Comment #5
drupalprog CreditAttribution: drupalprog commentedHi,
I already set cors on service.yml on drupal end
also i tried set a app inside drupal like you suggested
http://localhost/d8angular/drupal8/web/app
but same issue i got uid=0.
one more i need to point out ..if i have cors then i should not access drupal site but i got data via rest from drupal & its showing on
app too(on banner its dynamic data showing from drupal block)?
can you suggest what i need to do?
thanks
Comment #6
drupalprog CreditAttribution: drupalprog commentedHi,
if i try to load node then its showing the node title in console
but not related to user
jDrupal.nodeLoad(1).then(function(node) {
console.log( node.getTitle());
});
do you think its a issue to get current user logged(i.e. jDrupal.connect())?
i did some more debugging & found when i use your rest api path in vue i.e
http://localhost/d8angular/drupal8/web/jdrupal/connect?_format=json
then its showing same uid=0
& when i hit this in same browser then its showing uid=1 with role=admin
thanks
Comment #7
drupalprog CreditAttribution: drupalprog commentedHi,
Any reply?
thanks
Comment #8
tyler.frankenstein CreditAttribution: tyler.frankenstein commentedMaybe this is related: https://github.com/signalpoint/jDrupal/issues/87