self.$setState in app.js. How to get correct context?

I am new to web developement and framework7. I am creating an app and I wanted to send a request when the page gets mounted and use the response to update the html. In html file, the code is: <script> return { data: function () { return { loading: true, banners: [], declaring: this, } }, methods: { pass_data: function (index) { var self = this; // if (self.loading) return; self.$setState({ loading: true, }); } }, } </script>

And in app.js, I have following code:

$$(document).on(‘page:mounted’, ‘.page[data-name=“view_all”]’, function (e) {
// Do something here when page with data-name=“about” attribute loaded and initialized
// console.log(‘business’);
app.dialog.preloader(‘Loading Banners…’)
app.request.get(‘https://requestishere.php’, { auth_token:‘bar’ }, function (data) {
app.dialog.close();
// console.log(data);
var obj = JSON.parse(data);
var response = obj.banner;
// console.log(response);
var page = $$(’.page[data-name=“view_all”]’)[0].f7Page;
// page.banners = response;
console.log(page);
// page.loading = false;
var self = this;
self.$setState({
loading: true,
});
console.log(page.loading);
for(var k in response) {
console.log(response[k]);
if(response[k] instanceof Object) {
// printValues(response[k]);
} else {
// document.write(response[k] + “
”);
};
}
});
})

I am getting the following error: TypeError: self.$setState is not a function

I am guessing it is something to do with var self = this;, but, I have no idea how to get the correct context in app.js in page methods. Can someone please help me out here?

<script> return { 
        data: function () {
        // .....
        },
        method:{
            // your methods....
        }          
      on:{
          // use any of the following page events
          pageInit:function(){},
          pageAfterin:function(){},
          pageMounted:function(){},
      }
    }
    </script>

ALSO TAKE A LOOK AT =>
https://framework7.io/docs/page.html#page-events

good luck !!!

Tried this. It didn’t work

So, I was able to solve this :

var page = $$(’.page[data-name=“view_all”]’)[0].f7Page;
var self = page.$el[0].f7Component;
self.$setState({
loading: false,
});

I use this error occurs, please help

Uncaught TypeError: self.$setState is not a function
at Object.success (app.js:285)
at n (0:3999)
at XMLHttpRequest.Request.f.onload (0:4177)