I am working on Laravel / Vue project.
Inside blade i am including <account-users /> vue component. This component is performing a ajax call to get all the account users and show them in table.
Currently I am working / testing the app locally.
What I am noticing is that the the component ajax is receiving and displaying the data before the whole page has been fully loaded.
That can be easily seen if I duplicate the tab in chrome or if I right click to view the page source, what I first see is something like this (chrome auto formats the jason) :
[
{
"name": "25 person",
"email": "[email protected]",
"email_verified_at": null,
"id": 49,
"is_active": 0,
"roles": [
{
"name": "Foreman",
"id": 3,
"pivot": {
"model_id": 49,
"role_id": 3,
"model_type": "App\User"
}
}
],
"companies": [
{
"name": "Test company",
"id": 1,
"pivot": {
"user_id": 49,
"company_id": 1
}
Only after I refresh the page, the whole page gets displayed correctly.
From what I understand, the <account-user /> data is loaded before browser renders the whole html.
In vue component, the mounted() function triggers the data load function.
This really wouldn't be an application that I would want to post publicly for few reasons:
- User will notice that something is not right, therefore will loos trust in application
- Security - the application may flash the jason with some info, that is better if user don't know (i.e. ids....)
- Why, sometimes do I see the jason before the full page load?
- What would be the recommended approach to render the table data?
The reason why I want vue to render the table data is so all the crud functionality can be done via ajax (no page reloads).
Please let me know your thoughts on what would be the recommended way to render the data through vue, so I can have the crud functionality through ajax.