Data not loading after login / just after reshreshing page
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
add a comment |
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
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
add a comment |
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
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
java angularjs spring
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
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. :)
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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. :)
add a comment |
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. :)
add a comment |
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. :)
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. :)
edited Nov 13 '18 at 13:55
answered Nov 13 '18 at 13:38
temptemp
1258
1258
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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