Data not loading after login / just after reshreshing page










0















I got an simple login on my page. After logging in I'm displaying data from a server, that is just shown after refreshing the page once.
Before I am getting an Error 500:



GET http://localhost:8080/getDesktop 500
angular.js:14800 Possibly unhandled rejection: ...


My AngularJS code is the following:



var app = angular.module("myApp", );

app.controller("myCtrl", function($scope, $http, $window, $timeout)

//Username
$scope.user = "";

//Desktop
$scope.storage = ;

//Get username

$http.get("/loggeduser", transformResponse: function(response)
return JSON.stringify(response);

).then(function(response)
$scope.user = response.data.substring(1, response.data.length-1);
);

//Show Desktop

$http.get("/getDesktop").then(function(response)
for(var i = 0; i<response.data.length; i++)
$scope.storage[i] = name: response.data[i];

return;
);
);


Backend:



//Returns Desktop
@GetMapping("/getDesktop")
public ArrayList<String> getDesktop() throws Exception
ArrayList<String> itemNames = new ArrayList<>();

if(kdxF.getUser() != null)
itemNames = kdxF.showDesktop();
// Just a function to return the Elements in an ArrayList if Strings
// If user is logged in
else
throw new Exception("Not logged in!");


return itemNames;



And I get the message "Not logged in"










share|improve this question
























  • 500 is server-side error, you need to show your backend code

    – Aleksey Solovey
    Nov 13 '18 at 13:13











  • Added the code.

    – temp
    Nov 13 '18 at 13:15















0















I got an simple login on my page. After logging in I'm displaying data from a server, that is just shown after refreshing the page once.
Before I am getting an Error 500:



GET http://localhost:8080/getDesktop 500
angular.js:14800 Possibly unhandled rejection: ...


My AngularJS code is the following:



var app = angular.module("myApp", );

app.controller("myCtrl", function($scope, $http, $window, $timeout)

//Username
$scope.user = "";

//Desktop
$scope.storage = ;

//Get username

$http.get("/loggeduser", transformResponse: function(response)
return JSON.stringify(response);

).then(function(response)
$scope.user = response.data.substring(1, response.data.length-1);
);

//Show Desktop

$http.get("/getDesktop").then(function(response)
for(var i = 0; i<response.data.length; i++)
$scope.storage[i] = name: response.data[i];

return;
);
);


Backend:



//Returns Desktop
@GetMapping("/getDesktop")
public ArrayList<String> getDesktop() throws Exception
ArrayList<String> itemNames = new ArrayList<>();

if(kdxF.getUser() != null)
itemNames = kdxF.showDesktop();
// Just a function to return the Elements in an ArrayList if Strings
// If user is logged in
else
throw new Exception("Not logged in!");


return itemNames;



And I get the message "Not logged in"










share|improve this question
























  • 500 is server-side error, you need to show your backend code

    – Aleksey Solovey
    Nov 13 '18 at 13:13











  • Added the code.

    – temp
    Nov 13 '18 at 13:15













0












0








0








I got an simple login on my page. After logging in I'm displaying data from a server, that is just shown after refreshing the page once.
Before I am getting an Error 500:



GET http://localhost:8080/getDesktop 500
angular.js:14800 Possibly unhandled rejection: ...


My AngularJS code is the following:



var app = angular.module("myApp", );

app.controller("myCtrl", function($scope, $http, $window, $timeout)

//Username
$scope.user = "";

//Desktop
$scope.storage = ;

//Get username

$http.get("/loggeduser", transformResponse: function(response)
return JSON.stringify(response);

).then(function(response)
$scope.user = response.data.substring(1, response.data.length-1);
);

//Show Desktop

$http.get("/getDesktop").then(function(response)
for(var i = 0; i<response.data.length; i++)
$scope.storage[i] = name: response.data[i];

return;
);
);


Backend:



//Returns Desktop
@GetMapping("/getDesktop")
public ArrayList<String> getDesktop() throws Exception
ArrayList<String> itemNames = new ArrayList<>();

if(kdxF.getUser() != null)
itemNames = kdxF.showDesktop();
// Just a function to return the Elements in an ArrayList if Strings
// If user is logged in
else
throw new Exception("Not logged in!");


return itemNames;



And I get the message "Not logged in"










share|improve this question
















I got an simple login on my page. After logging in I'm displaying data from a server, that is just shown after refreshing the page once.
Before I am getting an Error 500:



GET http://localhost:8080/getDesktop 500
angular.js:14800 Possibly unhandled rejection: ...


My AngularJS code is the following:



var app = angular.module("myApp", );

app.controller("myCtrl", function($scope, $http, $window, $timeout)

//Username
$scope.user = "";

//Desktop
$scope.storage = ;

//Get username

$http.get("/loggeduser", transformResponse: function(response)
return JSON.stringify(response);

).then(function(response)
$scope.user = response.data.substring(1, response.data.length-1);
);

//Show Desktop

$http.get("/getDesktop").then(function(response)
for(var i = 0; i<response.data.length; i++)
$scope.storage[i] = name: response.data[i];

return;
);
);


Backend:



//Returns Desktop
@GetMapping("/getDesktop")
public ArrayList<String> getDesktop() throws Exception
ArrayList<String> itemNames = new ArrayList<>();

if(kdxF.getUser() != null)
itemNames = kdxF.showDesktop();
// Just a function to return the Elements in an ArrayList if Strings
// If user is logged in
else
throw new Exception("Not logged in!");


return itemNames;



And I get the message "Not logged in"







java angularjs spring






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 13:15







temp

















asked Nov 13 '18 at 13:11









temptemp

1258




1258












  • 500 is server-side error, you need to show your backend code

    – Aleksey Solovey
    Nov 13 '18 at 13:13











  • Added the code.

    – temp
    Nov 13 '18 at 13:15

















  • 500 is server-side error, you need to show your backend code

    – Aleksey Solovey
    Nov 13 '18 at 13:13











  • Added the code.

    – temp
    Nov 13 '18 at 13:15
















500 is server-side error, you need to show your backend code

– Aleksey Solovey
Nov 13 '18 at 13:13





500 is server-side error, you need to show your backend code

– Aleksey Solovey
Nov 13 '18 at 13:13













Added the code.

– temp
Nov 13 '18 at 13:15





Added the code.

– temp
Nov 13 '18 at 13:15












1 Answer
1






active

oldest

votes


















0














Okay, I solved it with a kinda ugly solution, but it works.
I'm constantly checking if the user is null, then loading the data.



//Returns Desktop
@GetMapping("/getDesktop")
public ArrayList<String> getDesktop() throws Exception
ArrayList<String> itemNames = new ArrayList<>();
int kill = 0;

while(kdxF.getUser() == null) // FIXME
if(kill == 500)
break;
else
Thread.sleep(5);
kill++;



itemNames = kdxF.showDesktop();

return itemNames;



If you get a better suggestion please tell me. :)






share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53281758%2fdata-not-loading-after-login-just-after-reshreshing-page%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Okay, I solved it with a kinda ugly solution, but it works.
    I'm constantly checking if the user is null, then loading the data.



    //Returns Desktop
    @GetMapping("/getDesktop")
    public ArrayList<String> getDesktop() throws Exception
    ArrayList<String> itemNames = new ArrayList<>();
    int kill = 0;

    while(kdxF.getUser() == null) // FIXME
    if(kill == 500)
    break;
    else
    Thread.sleep(5);
    kill++;



    itemNames = kdxF.showDesktop();

    return itemNames;



    If you get a better suggestion please tell me. :)






    share|improve this answer





























      0














      Okay, I solved it with a kinda ugly solution, but it works.
      I'm constantly checking if the user is null, then loading the data.



      //Returns Desktop
      @GetMapping("/getDesktop")
      public ArrayList<String> getDesktop() throws Exception
      ArrayList<String> itemNames = new ArrayList<>();
      int kill = 0;

      while(kdxF.getUser() == null) // FIXME
      if(kill == 500)
      break;
      else
      Thread.sleep(5);
      kill++;



      itemNames = kdxF.showDesktop();

      return itemNames;



      If you get a better suggestion please tell me. :)






      share|improve this answer



























        0












        0








        0







        Okay, I solved it with a kinda ugly solution, but it works.
        I'm constantly checking if the user is null, then loading the data.



        //Returns Desktop
        @GetMapping("/getDesktop")
        public ArrayList<String> getDesktop() throws Exception
        ArrayList<String> itemNames = new ArrayList<>();
        int kill = 0;

        while(kdxF.getUser() == null) // FIXME
        if(kill == 500)
        break;
        else
        Thread.sleep(5);
        kill++;



        itemNames = kdxF.showDesktop();

        return itemNames;



        If you get a better suggestion please tell me. :)






        share|improve this answer















        Okay, I solved it with a kinda ugly solution, but it works.
        I'm constantly checking if the user is null, then loading the data.



        //Returns Desktop
        @GetMapping("/getDesktop")
        public ArrayList<String> getDesktop() throws Exception
        ArrayList<String> itemNames = new ArrayList<>();
        int kill = 0;

        while(kdxF.getUser() == null) // FIXME
        if(kill == 500)
        break;
        else
        Thread.sleep(5);
        kill++;



        itemNames = kdxF.showDesktop();

        return itemNames;



        If you get a better suggestion please tell me. :)







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 13 '18 at 13:55

























        answered Nov 13 '18 at 13:38









        temptemp

        1258




        1258



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53281758%2fdata-not-loading-after-login-just-after-reshreshing-page%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Top Tejano songwriter Luis Silva dead of heart attack at 64

            ReactJS Fetched API data displays live - need Data displayed static

            政党