[SOLVED] Framework7 CLI / Cordova / PWA

I’m starting with framework7-cli, I created a project with cordova and pwa, it works 100%, now I wanted to create other files that contain my crud functions, but I do not know how to call those new functions in my route file

import HomePage from '../pages/home.f7.html';
import AboutPage from '../pages/about.f7.html';
import FormPage from '../pages/form.f7.html';

import DynamicRoutePage from '../pages/dynamic-route.f7.html';
import RequestAndLoad from '../pages/request-and-load.f7.html';
import NotFoundPage from '../pages/404.f7.html';

import user from '../js/user.js';

var routes = [
        path: '/',
        async: function (routeTo, routeFrom, resolve, reject) {
            var router = this;
            var app = router.app;
            resolves ({component: HomePage});
        on: {
            pageBeforeIn: function (event, page) {
                // * Cause error
                console.log (listUsers());
export default routes;

The listing function:

function listUsers () {
    const list = [{name: "Test", email: "[email protected]"}];
    return list;

When I call this function inside the routes, the following error occurs:
// * Error

Uncaught ReferenceError: listUsers is not defined
    at Router.pageBeforeIn (routes.js: 28)
    at HTMLDivElement.handleEvent (dom7.module.js: 407)
    at Dom7.trigger (dom7.module.js: 569)
    at Router.pageCallback (router-class.js: 954)
    at Router.forward (navigate.js: 469)
    at resolve (navigate.js: 671)
    at eval (component-loader.js: 89)
    at compile (component-loader.js: 38)
    at Router.componentLoader (component-loader.js: 70)
    at Router.pageComponentLoader (component-loader.js: 87)

I still do not understand how it works, thank you right now for the understanding and attention of all!

// list-user.js
function listUsers () {
    const list = [{name: "Test", email: "[email protected]"}];
    return list;
export default listUsers;

In your routes.js

import listUsers from './path/to/list-users.js';

// now you can reference it in routes file
1 Like

From what I understand now you are exporting only one function, but if I have more than one function in this user.js file, how would I export all the functions?

There are numerous ways of how to do it. Learn how ES modules work in JavaScript to get the understanding:

1 Like

It has multiple export:

export { func1, func2, func3 };


import { func1 } from './....';
1 Like

Ok now it’s clear, I’m going to read the documentation you passed, thank Vladimir for the explanation, and congratulations for the excellent work with framework7-cli.