bykof / cordova-plugin-webserver

A webserver plugin for cordova
Other
124 stars 49 forks source link

Uncaught ReferenceError: webserver is not defined #40

Open pr46 opened 5 years ago

pr46 commented 5 years ago

Hi I'm tryng to use the plugin but i receive this error. I think it's an injection error, but i didn't see the injection variables name in documentation. I put the code inside the deviceready event. Can someone help Me? thanks Paolo

`$ionicPlatform.ready(function() {

 webserver.onRequest(
function(request) {
    console.log("O MA GAWD! This is the request: ", request);

    webserver.sendResponse(
        request.requestId,
        {
            status: 200,
            body: '<html>Hello World</html>',
            headers: {
                'Content-Type': 'text/html'
            }
        }
    );
}

);

webserver.start(function(){console.log("it's working");}); });`

EmadFani commented 5 years ago

same here any news ?

shangzhenyang commented 4 years ago

I solved this by adding <script src="cordova.js"></script> into the HTML file.