0

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.

1 Answer 1

0

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()))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.