Description
I'm implementing a $ http request with angular. I want to return the objects from the database.
Code
CompanyService.coffee
angular.module('vaultfactor').factory 'CompanyService', ($http, $q) ->
getCompanies: ->
promise = $http.get "/companies"
company = promise.then((response)->
if typeof response.data == 'object'
console.log(response.data)
return response.data
else
return $q.reject(response.data)
(response)->
$q.reject(response.data))
main_ctrl.coffee
angular.module('vaultfactor').controller 'HomeCtrl', ($scope, $rootScope,
$location, $http, CompanyService) ->
console.log(CompanyService.getCompanies())
Problem
The returned object is not the template you expected.
Givenaconsole.loginmyresponse.databeforethereturnitreturnsmeexactlywhatIneed.so:(It'sbeingpassedinthedependencies$q,I'vepostedanolderimage.)
Console.log:
What am I missing in the return of my success?