I have successfully tested the http request in Postman and it seems to be functioning properly.
https://m.socialnetwk.com/home/app/feed_load.php?id=4235
This request returns the following:
[
{
"firstname": "4235",
"lastname": "Round",
"profile_image": "jpg/55529055162cf0.jpg",
"lastname": "Round",
"iframe": "",
"media_format": "img",
"media_file_format": "jpg",
"media_post_id": "5851875bda5b3",
"media_author_id": "3",
"mediatxt": ""
},
{
"firstname": "4235",
"lastname": "Round",
"profile_image": "jpg/55529055162cf0.jpg",
"lastname": "Round",
"iframe": "",
"media_format": "img",
"media_file_format": "jpg",
"media_post_id": "583c459a745a4",
"media_author_id": "3",
"mediatxt": ""
},
{
"firstname": "4235",
"lastname": "Round",
"profile_image": "jpg/55529055162cf0.jpg",
"lastname": "Round",
"iframe": "",
"media_format": "img",
"media_file_format": "jpg",
"media_post_id": "583c4597778c1",
"media_author_id": "3",
"mediatxt": ""
}
]
The issue appears to be related to this line of code:
$scope.session_id = sessionStorage.getItem('session_id');
Upon printing $scope.session, it returns as undefined, causing the http request to return an empty array.
Let's resolve this issue
Make sure to inject sessionStorage. If you are using ngStore, you need to inject $sessionStorage.
Here is an example:
.controller('feedCtrl', function($scope,$rootScope,$ionicHistory,$state,$http, $sessionStorage )
Update your code snippet as follows:
$scope.session_id = $sessionStorage.getItem('session_id');
$http.get('' + $scope.session_id).then(function(response) {
$scope.records = response.data;
});
As mentioned by Jackk.
Apologies for any errors in my English.