Utilizing RestHeart to expose CRUD functionality from MongoBD. Attempting to call the Rest API from AngularJS and retrieve the JSON output like the one displayed below. My focus is specifically on extracting the name, age, & city fields that are stored in MongoDB.
However, I am uncertain about how to fetch these values.
Javascript code:-
crudApp.controller('listController', function($scope, $http, $location,
crudService) {
$http.get('http://localhost:8081/jaydb/employees').success(
function(response) {
console.log('response : ' +JSON.stringify(response));
$scope.employees = response;
});
})
JSON Result from REST API
{
_embedded: {
rh: doc: [
{
_embedded: {
},
_links: {
self: {
href: "/jaydb/employees/55c1e7c41c49a8cd78818bc7"
},
rh: coll: {
href: "/jaydb"
},
curies: [
{
href: "http://www.restheart.org/docs/v0.10/#api-doc-{rel}",
name: "rh"
}
]
},
_type: "DOCUMENT",
_id: {
$oid: "55c1e7c41c49a8cd78818bc7"
},
name: "Anupama", city: "Trichy", age: 25,
_etag: {
$oid: "55c1e7c41c49a8cd78818bc8"
},
_lastupdated_on: "2015-08-05T10:39:00Z",
_created_on: "2015-08-05T10:39:00Z"
},
{
_embedded: {
},
_links: {
self: {
href: "/jaydb/employees/55c1e7ae1c49a8cd78818bc5"
},
rh: coll: {
href: "/jaydb"
},
curies: [
{
href: "http://www.restheart.org/docs/v0.10/#api-doc-{rel}",
name: "rh"
}
]
},
_type: "DOCUMENT",
_id: {
$oid: "55c1e7ae1c49a8cd78818bc5"
},
name: "Sujatha",
city: "Chennai",
age: 24,
_etag: {
$oid: "55c1e7ae1c49a8cd78818bc6"
},
_lastupdated_on: "2015-08-05T10:38:38Z",
_created_on: "2015-08-05T10:38:38Z"
},
{
_embedded: {
},
_links: {
self: {
href: "/jaydb/employees/55c1e7981c49a8cd78818bc3"
},
rh: coll: {
href: "/jaydb"
},
curies: [
{
href: "http://www.restheart.org/docs/v0.10/#api-doc-{rel}",
name: "rh"
}
]
},
_type: "DOCUMENT",
_id: {
$oid: "55c1e7981c49a8cd78818bc3"
},
name: "Soniya", city: "Ernakulam", age: 22,
_etag: {
$oid: "55c1e7981c49a8cd78818bc4"
},
_lastupdated_on: "2015-08-05T10:38:16Z",
_created_on: "2015-08-05T10:38:16Z"
},
{
_embedded: {
},
_links: {
self: {
href: "/jaydb/employees/55c1e7711c49a8cd78818bc1"
},
rh: coll: {
href: "/jaydb"
},
curies: [
{
href: "http://www.restheart.org/docs/v0.10/#api-doc-{rel}",
name: "rh"
}
]
},
_type: "DOCUMENT",
_id: {
$oid: "55c1e7711c49a8cd78818bc1"
},
name: "Reshma", city: "Trivandrum", age: 21,
_etag: {
$oid: "55c1e7711c49a8cd78818bc2"
},
_lastupdated_on: "2015-08-05T10:37:37Z",
_created_on: "2015-08-05T10:37:37Z"
},
{
_embedded: {
},
_links: {
self: {
href: "/jaydb/employees/55c1d3a8b216e0710f8ee0ab"
},
rh: coll: {
href: "/jaydb"
},
curies: [
{
href: "http://www.restheart.org/docs/v0.10/#api-doc-{rel}",
name: "rh"
}
]
},
_type: "DOCUMENT",
_id: {
$oid: "55c1d3a8b216e0710f8ee0ab"
},
name: "Michael", city: "Tokyo", age: 23,
_created_on: "2015-08-05T09:13:12Z"
}
]
}, _links: {
},
_type: "COLLECTION",
_id: "employees",
_created_on: "2015-08-05T09:38:36Z",
_etag: {
$oid: "55c1d99c1c49a8cd78818bb6"
},
_lastupdated_on: "2015-08-05T09:38:36Z",
_collection-props-cached: false,
_returned: 5
}
Ref: