bykof / cordova-plugin-webserver

A webserver plugin for cordova
Other
119 stars 51 forks source link

'webserver' is not defined #58

Closed AEiosApp closed 4 years ago

AEiosApp commented 4 years ago

Hi, I'm trying to add your solution to my Vuejs cordova project, but getting the error from eslint: 'webserver' is not defined It marks in red 'webserver' in the code, when I'm calling: webserver.onRequest() webserver.sendResponce() wenserver.start()

How to define 'webserver' in the project? From which file should I import it?

bykof commented 4 years ago

You cannot import webserver, because the object gets injected by cordova. You can ignore the global variable by eslint:

/*global webserver */
AEiosApp commented 4 years ago

@bykof thanks for quick reply! Actually, that wasn't related with your plugin, but with using cordova plugins in Vuejs. Just in case anybody will use it with vue, what was working for me:

  1. Adding to index.templete.html: <script src="cordova.js"></script>

  2. Call webserver methods with window, e.g.:

    window.webserver.onRequest()
    window.webserver.sendResponce()
    window.webserver.start()