Call Cordova plugin in routes.js

Tried to use cordova-plugin-advanced-http in my framework7 app.
I want to call cordova.plugin.http in async route, but have no idea how to call the plugin.

async: function (routeTo, routeFrom, resolve, reject) {
var router = this;
var app =;

Here how can I call cordova object?
I have tried
but all failed.

Thats probably because the Cordova plugins aren’t yet initialized and available when you load your routes. To overcome this, I’ve delayed the framework7 initialization and put my routes inside a function like this:

var f7app = new Framework7({
  init: false,

Then my routes.js contains something like this:

function load_routes() {
    return {
      ... regular routes object ...

And in my deviceready callback, I load the routes and initialize Framework7:

<body onload="document.addEventListener('deviceready', my_init_callback, false);">

function my_init_callback() {
  f7app.routes = load_routes();

Exact code depends on your app, but I hope you get the point of delaying the route generation and Framework7 initialization by using the deviceready event.

1 Like

or just window.cordova