Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

I am working with webapp2 and Angular's $resource, I am having hard time finishing the job and resolving my data array from JSON format within my controller.

in my python handler, the array wrapper to JSON format is as follows:

self.response.write(json.encode(self.getVertices()))

and here is my service code in Angular:

angular.module('myPage').service('onServices',['$resource','$q', 
function($resource,$q){
   this.getMesh = function(){
   var Mesh = $resource('/context/actors/one',
   {}, {get: {method:'GET', isArray:true,responseType:'json'}})
   return Mesh.get().$promise.then(function(data) {
               one = data
               return one})   
}
}]);

and my controller code is this:

$scope.bck =  onServices.getMesh();

when I log 'data' inside the service, it shows as series of 'resource' each of which containing a row of the array. And when I log the data inside the controller, it is still in 'promise' format, which contains the series of 'resource' (array rows). I can see the data inside the promise, but I am not seeing the data in the expected format, which is JSON. thanks.

share|improve this question

Do you get JSON when you call the python part? Have you tried this Python JSON docs

self.response.headers['content-type'] = 'text/plain'
self.response.write(json.dumps(self.getVertices()))
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.