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!