Calling a function from app.request

Hi,

so far I was successful to build my first Framework7 app - easier than I expected :grinning:

But with one problem I always hit the wall. Presumably a consequence of my limited javascript experience but maybe someone can help me.

In the result of a request I need to call another method or have access to Framework7.
For example after retrieving some data from a server with Framework7.request I want to call a function loginOK. This is not possible because loginOK is not recognized. Directly calling router.navigate(’/’); is also not possible.

<script>
 export default {
 methods:
  {
      signIn() {
        var $ = this.$;
        var app = this.$app;
        var router = this.$router;
        var username = $('input#demo-username-2').val();
        var password = $('input#demo-password-2').val();
         var param = {'username': username, 'password': password};
       
		app.request.json('//localhost:8081/4DAction/W_CheckPassword', param, function(data){
			
			loginOK(data)}); 
			
	},
	
	   loginOK(data){
  		  var $ = this.$;
        var app = this.$app;
        var router = this.$router;
if (data.success){
 			router.navigate('/');
…

What do I miss?

methods:
  {
    signIn() {
      var self = this;
      ...
      app.request.json('...', ..., function(data){
        self.loginOk(data);
      }); 
    
  },
      
          

don’t have much time to deduce your issue but give arrow functions a try as in my example below.
app.request.json(’//localhost:8081/4DAction/W_CheckPassword’, param,(data) => {
loginOK(data);
});

Thanks, but same problem:
Uncaught ReferenceError: loginOK is not defined

what flavour of F7 are you using?

actually @nolimits4web solution should do the trick for you. I presume you are doing vuejs

Thanks, but

self.loginOK is not a function

Bildschirmfoto 2020-04-17 um 20.02.01

Edit: wrong Screenshot. app: not available

Plain Framework7 Core

Thank you - slept one night and tried again, now it works. Not a clue what I did yesterday.