bykof / cordova-plugin-webserver

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

Uncaught ReferenceError: webserver is not defined #40

Open pr46 opened 4 years ago

pr46 commented 4 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 4 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.