-2
I am creating a menu for my application Ionic 3, and I came across the following problem: In this menu I bring data from the user coming from the database, these data I load in the app.component.ts, but it searches this data before the client log in and the error pq still does not have the data, and when I take it to load right away obviously it is necessary to give a refresh in the application so that the data appear in the menu, if contract is without the data. I wanted to know how to get the.Component app to load right after the user logs in. Thank you.
Your question is strange, because if you have already developed the app.Component with database query and everything, so you should already know that you need a login system, with token generation and bank verification and everything else a login needs to be the entry port of your application.
– LeAndrade
Who says you don’t? I think you don’t understand the question, I made the menu after creating all this, in the app.Component I give a get on the data of the logged in user, the problem is that this is only possible after it login, and what happens is that when you arrive at the login page the app.Component is already loaded and generates an error on the screen saying that the user id is null, which is really why it hasn’t logged in
– israel
i wanted to know how to call the app.Component only after the user logs in, I did an if and put it to load only when the id is not null, the problem is that when the user logs in the menu comes empty and only the data appears after giving a F5 on the screen
– israel
Okay, now it’s clearer, so this you have to define by creating routes.
– LeAndrade
How would it work ? pq realized that the app.Component only loads when the app opens or when it updates the page
– israel
Face this is subject for an entire course module, is very broad, there is no way to explain here, depends on the structure that the app was made, the language in the back end and many other issues.
– LeAndrade
basically if the id is null is pq the user is not logged in right? then just direct to the login, and this can be done with the routes as @Leandrade mentioned
– Ricardo Pontual
Ricardo that is done, my problem is that the menu always carries null, understood ? the Component app is only loaded once when you open the app, then it is only closed if I update the page, and after the update the data appears
– israel
Low quality question. Add information to help you.
– Maury Developer
Maury, if you spent a little time looking at the answer below, you would see that it has already been solved!
– israel