Cannot read property 'post' of undefined

Hello
i cant make request.
Error:
Cannot read property ‘post’ of undefined

My app.js file:

import $$ from 'dom7';
import Framework7 from 'framework7/framework7.esm.bundle.js';

// Import F7 Styles
import 'framework7/css/framework7.bundle.css';

// Import Icons and App Custom Styles
import '../css/icons.css';
import '../css/app.css';
// Import Cordova APIs
import cordovaApp from './cordova-app.js';
// Import Routes
import routes from './routes.js';

//var malcome = new crypto();

var app = new Framework7({
    root: '#app', // App root element
    id: 'com.fxteam.game', // App bundle ID
    name: 'game', // App name
    theme: 'auto', // Automatic theme detection
    // App root data
    data: function () {
    return {
        user: {
        firstName: 'John',
        lastName: 'Doe',
        },

    };
    },
    // App root methods
    methods: {
    helloWorld: function () {
        app.dialog.alert('Hello World!');
    },
    },
    // App routes
    routes: routes,


    // Input settings
    input: {
    scrollIntoViewOnFocus: Framework7.device.cordova && !Framework7.device.electron,
    scrollIntoViewCentered: Framework7.device.cordova && !Framework7.device.electron,
    },
    // Cordova Statusbar settings
    statusbar: {
    iosOverlaysWebView: true,
    androidOverlaysWebView: false,
    },
    on: {
    init: function () {
        var f7 = this;
        if (f7.device.cordova) {
        // Init cordova APIs (see cordova-app.js)
        cordovaApp.init(f7);
        }
    },
    },
    touch: {
    fastClicks: true,
    tapHold: true //enable tap hold events
    }
});

import bcrypt from './bcrypt.js';
import sjcl from './sjcl.js';
import game from './crypto.js';

crypto.js:

//some code ...
var game = game || {};
game.crypto = function() {
    var login = function(user, pin, url, callback, store, restore) {
        app.request.post( //<-- error 'Cannot read property 'post' of undefined'
                url, {},
                async function (data) {
                    //success
                },
                function (xhr, data) {
                    app.preloader.hide();
                    app.dialog.alert(checkErrorCode(data));
        }, "json");
    }

    //code ...
}();
export default game;

I also tried to use Framework7 instead of app, but the result was same.

Try
app => window.app
In 2 place

2 Likes