angularjs - Using Angular.js $resource of $http.get to display results from json API -


i'm trying switch sourcing json locally fetching api. i've had working locally, can't seem access when requesting using api. formatting must incorrect, i'm not sure i'm searching that's incorrect.

this way i've been getting json local directory before moving api:

countclocks.factory('thisclock', ['$resource',  function($resource){  return $resource('clocks/:clockid.json', {}, {  query: {method:'get', params:{clockid:'clock'}, isarray:true}  }); }]); 

my current json cones file called clocks.json , looks this:

{ "id": "ch-1", "slug": 1, "title": "ch 1 name",  "content": "some text orange clocks" } 

i've tried switching resource url , parameters, haven't had luck. here's format changed to:

countclocks.factory('thisclock', ['$resource',  function($resource){  return $resource('http://www.example.org/api/get_tag_posts/?tag_slug=clocks', {}, {  query: {method:'get', params:{clockid:'clock'}, isarray:true}  }); }]); 

and new json looks like:

{  "status":"ok",  "count":10,  "count_total":12,  "pages":2,  "posts":[     {      "id":51,      "slug":"chapter1",      "url":"http:\/\/www.orangeclocks.com\/chapter1\/",      "title":"chapter 1",      "content":"<p>it would be great to live here.<img class=\"alignleft\" alt=\"\" src=\"http:\/\/lorempixel.com\/600\/400\/nature\/3\/\" width=\"600\" height=\"400\" \/><\/p>\n",      "excerpt":"<p>it would be great to live here.<\/p>\n",      },      {      "id":49,      "slug":"chapter2”,      "url":"http:\/\/www.orangeclocks.com\/chapter2\/",      "title":"chapter 2”,      "content":"<p>&nbsp;<\/p>\n<p>big little.<br \/>\n<img class=\"alignleft\" alt=\"\" src=\"http:\/\/lorempixel.com\/600\/400\/nature\/2\/\" width=\"600\" height=\"400\" \/><\/p>\n",       }      ] } 

you using absolute url http://www.example.org/api/get_tag_posts/?tag_slug=clocks

1) if example.org on different domain application, running cross-domain request issues. aren't allowed make cross-domain requests unless domain allows in response headers resource.

2) defined url parameter clockid in query action, url using doesn't include it. if it's static url need, remove parameter.

do little debugging in browser. if getting valid response server, @ json in reponse , make sure matches expecting. console errors.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -