Topic: Displaying row data in mdbtable using api call
evioxtech pro asked 6 years ago
} ], rows: [] } }; }, mounted() { axios({method: "GET", "url": "http://localhost:8000/api/v1/product/10"}).then(result => { this.rows = result.data; console.log(this.rows.name); }, error => { console.error(error); });
Webbkameror.se free answered 5 years ago
I just noticed the error in the documentation. And I can't believe I didn't spot it earlier. The attribute value should be in both double quotes and in single quotes: like this: "'https://YOUR_API_URL'"
. This will make the API-URL version work.
Magdalena Dembna staff commented 5 years ago
Hi, thank you for letting us know about this mistake. Kind regards, Magdalena
Webbkameror.se free answered 5 years ago
I am using your Vue Demo project to write code. I am getting the following error when following your advice:
- invalid expression: Unexpected token :
The "colon" is not valid and makes the App crash
Mikołaj Smoleński staff commented 5 years ago
Hi there, In our demo there is an example with datatables API call. Is it also not working properly?
Mikołaj Smoleński staff answered 5 years ago
evioxtech pro answered 5 years ago
:data="https://YOUR_API_URL" ?
Mikołaj Smoleński staff answered 5 years ago
<template> <mdb-datatable :data="https://YOUR_API_URL" striped bordered /> </template> <script> import { mdbDatatable } from 'mdbvue'; export default { name: 'DatatablePage', components: { mdbDatatable } }; </script>Best Regards
evioxtech pro answered 5 years ago
mounted() { axios({method: "GET", "url": "http://localhost:8000/api/v1/product/10"}).then(result => { this.rows = result.data; console.log(this.rows.name); }, error => { console.error(error); }); I am passing rows data to the through the mounted function to the rows[] data field.But still not able to render it
Mikołaj Smoleński staff answered 5 years ago
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- ForumUser: Pro
- Premium support: No
- Technology: MDB Vue
- MDB Version: 4.6.0
- Device: Laptop
- Browser: Chrome
- OS: Mojave
- Provided sample code: Yes
- Provided link: Yes