I am facing an issue with displaying data in a UI grid table.
I have set up an API through which I can access the data in my browser, but I am encountering difficulties when it comes to rendering the data. Below is my Angular controller where I have defined a function to fetch data from the API:
getData();
$scope.myData = [];
$scope.gridOptions.data = []
$scope.gridOptions.data = $scope.myData;
function getData() {
$http.get('/load/').success(function (data) {
data.forEach( function( row, index ) {
$scope.myData.push(data);
});
$scope.gridOptions.data = data;
console.log('data from api', data);
})
};
However, when I try to display the data on the grid, it appears empty. https://i.sstatic.net/BVlDw.png
The data is visible in the console: https://i.sstatic.net/LXGoV.png
I also attempted to parse the data using var jsonObj = JSON.parse(data);
, but encountered an error
Unexpected token o
at Object.parse (native)