0

I'm extracting a JSON API URL in the framework ionic with AngularJs like the code below:

.factory('BuyApi', function($http) {
  var obj = {};

  obj.buy = function() {
    var api = "https://maiscarrinho.com/api/search?q=gato&pageNumber=0&pageSize=10";
    return $http.get(api);
  };
  return obj
})

.controller('MainControl', function($scope, BuyApi){

  $scope.produtos;

  BuyApi.buy().success(function(data) {
      $scope.data = data;
      $scope.produtos = data.results;
  })
});

For the JSON file I use this URL: https://maiscarrinho.com/api/search?q=gato&pageNumber=0&pageSize=10, but every time you do an refresh on the page data changes (more exactly the prices) and it does not happen in the actual site : https://maiscarrinho.com/search?q=gato.

So I did an investigation might it be because the request and response header? Do I need to pass parameter? or something?

7
  • It seems that on main page they are sorted the items by some field. Commented Apr 23, 2016 at 13:33
  • it don't seem like it, because it can't be sorted only by price i think. all the order aspects or rigth only the prices are changed. Commented Apr 23, 2016 at 13:42
  • that's the provider code: [maiscarrinho.com/api/provider/portugal] (maiscarrinho.com/api/provider/portugal) Commented Apr 23, 2016 at 13:55
  • It seems your problem is not with headers, neither with the code you have posted. Do you ever make a xhr call to 'maiscarrinho.com/api...' after the page loads? The data you see on the page come as HTML, from the first request. Try to add console.log(data) after BuyApi.buy().success(function(data) { and you won't probably see anything in the console since the call won't be made. Maybe your application does not initialise properly? Commented Apr 23, 2016 at 20:33
  • @Matej P. i do retrive the data sucessfull, that's not the problem. the problem is that the json file when refresh in chrome or other IE will change the data for no appearnt reason Commented Apr 23, 2016 at 22:11

0

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.