1

I have created a sample project where I am trying to hit a service which gives the Latitude and Longitude of a particular location. I have already deployed the adapter on the server and now I am trying to hit the adapter. When I try to do so, I get the error: WLResourceRequest is not defined in my js. Following is my code:

function locate() {

    var locat = document.getElementById('location').value;
    alert(locat);

    var resourceRequest = new WLResourceRequest(
            "/adapters/LocationAdapter/getGmapLatLng",
            WLResourceRequest.GET
    );

    resourceRequest.setQueryParameter("params", "['110064']");

    resourceRequest.send().then(
            function(response) {
                alert("Success\n\n" + response);
            },
            function(error) {
                alert("Failure\n\n" + error);
            }
        )
}
Gaurab Kumar
  • 2,144
  • 2
  • 17
  • 29
  • Is this a Cordova app ? Which platform are you trying on? Please specify the version of MobileFirst you're using. Also, ensure that you have added a reference to worklight.js in your html page – Srik Jun 15 '17 at 06:52
  • 1) Its a MFP 8.0 project. 2) I am on Android Emulator. 3) I cannot find worklight.js because in MFP 8.0, you get a cordova project and you have to include the mfp plugin. – Kush Thapar Jun 15 '17 at 07:05
  • 1
    If the worklight.js is not seen, then your plugin is not installed or not properly installed. Try removing and adding it again – Vivin K Jun 15 '17 at 10:32

2 Answers2

0

Add mfp plugin properly. If already added then remove it and add again.

cordova plugin add cordova-plugin-mfp

Gaurab Kumar
  • 2,144
  • 2
  • 17
  • 29
0

In your Config.xml: Define the plugin like this:

<plugin name="cordova-plugin-mfp" spec="8.0.2016101414"/>

then run the following command:

cordova prepare android
or
cordova platform remove android && cordova platform add android
srikanth Nutigattu
  • 1,077
  • 9
  • 15