I am trying to get a respose from node js. The call is made and in browser network i get correct response but when promise is resolved i get weird output.
to fetch in nodejs file
app.get('/hotel/hotelsList', function(req, res) {
res.send('hello world');
});
service call
angular.module('hotelApp.controller')
.controller('searchHotelCtrl', function($scope, $state, hotelService) {
$scope.$state = $state;
$scope.hi = 'hel';
function success(response) {
console.log(response);
};
$scope.hotelDetails = function() {
hotelService.fetchHotels('INDIA').then(success);
};
});
resource factory
$resource(url, params, {
get: {
method: 'get',
url: url
}
});
call to fetch hotels
function fetchHotels(country) {
var fetchHotels = resourceFactory(basePath+ '/hotelsList', {
params: {
country: country
}
});
retu fetchHotels.get().$promise;
}
Response is printed as
m {0: "h", 1: "e", 2: "l", 3: "l", 4: "o", 5: " ", 6: "w", 7: "o", 8: "r", 9: "l", 10: "d", $promise: d, $resolved: true}
Why is my response doesn't come as 'hello world' only ?
