5 Replies Latest reply on May 24, 2016 9:37 AM by Scott A Johnson

    Tip on using osapi.http.get


      If your app makes repeated calls to osapi.http.get you should be aware that the requests are cached in adherence with the specifications.  So if you read records, insert another record and requery you'll not see the new record because the first request is cached. 


      You can get around caching by specifying "refreshInterval" to control how long the cache persists.   Experimentation shows setting it to 0 stops the caching of the request.


          getNumberOfPropsGivenToday: function(callback) {

              var that = this;

              console.log(BACKEND_HOST + '/props/count?days_ago=1&giver_id=' + this.get('id'));


                  href: BACKEND_HOST + '/props/count?days_ago=40&giver_id=' + this.get('id'),

                  format: 'json',

                headers: {"Content-Type": ["application/json"]},

                 'refreshInterval': 0,

                  'authz': 'signed'

              }).execute(function(res) {

                  console.log("res = ",res);

                  console.log("res.content = ",res.content);

                  console.log("res.content.count = ", res.content.count);

                  if(res.content && res.content.hasOwnProperty('count')) {

                      callback(parseInt(res.content.count, 10));

                  } else {

                      console.log('error occurred getting # of props given today yo 22', res);






      Hope this helps someone