Maybe I should try using json.parse here, but I'm not sure how to go about it.
Userscontroller.php
function list(){
$clients = Clients::all();
$result["users"]=$clients;
return $result;
Here is the data:
{
"users": [
{
"id": 1,
"fullName": "Deniz",
"company": "Riskomer",
"role": "editor",
"username": "denden",
"country": "Türkiye",
"contact": "05355141450",
"email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d5bdb4b9b9bab7a7baede795b2b8b4bcb9fbb6bab8">[email protected]</a>",
"currentPlan": "Enterprise",
"status": "inactive",
"avatar": ""
},
I want it to look like this. Essentially, I need to convert the JSON object to a JavaScript object as shown below. How can I achieve this with Laravel?
users: [
{
id: 1,
fullName: 'Galen Slixby',
company: 'Yotz PVT LTD',
role: 'editor',
username: 'gslixby0',
country: 'El Salvador',
contact: '(479) 232-9151',
email: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5631253a3f2e342f661637343578383322783723">[email protected]</a>',
currentPlan: 'enterprise',
status: 'inactive',
avatar: '',
},