Page 1 of 5

Not able to retrieve data from a JavaScript Rest Service after the update

Posted: Tue Sep 23, 2014 8:53 am
by Asif

Hi,
I have one Javascript Rest Service in my project "getVegMenu".
In the javascript implementation of this service i am retrieving data from local DB
and then mapping it to a listItem on "posDashBoard" page.
I saw in the logs, value is coming from local DB but not get mapped to the list Item.

Before the update it was working.

Steps to replicate the issue

  1. Open the app and click on the panel Button on the top left corner of the page.
    Then click on Sync Menu list item.

  2. Then click on Veg button on the detail page.
    On this button i have called the JS Rest Service.

    I have shared my app with a href="mailto:support@appery.io" rel="nofollow"support@appery.io/a
    its name is POS
    Pls help..!!


Not able to retrieve data from a JavaScript Rest Service after the update

Posted: Tue Sep 23, 2014 10:28 pm
by Yurii Orishchuk

Hi Asif,

Unfortunatly i can not follow your steps to reproduce the problem.

See details: http://prntscr.com/4ppf0m/direct

Can you provide us details screen shots with steps?

Regards.


Not able to retrieve data from a JavaScript Rest Service after the update

Posted: Wed Sep 24, 2014 5:56 am
by Asif

Hi Yurii,
Please try to replicate it now.


Not able to retrieve data from a JavaScript Rest Service after the update

Posted: Wed Sep 24, 2014 10:45 pm
by Yurii Orishchuk

Hi Asif,

Still can not reproduce it.

See details what i see:
https://appery.io/app/rest/user/proje...

Can you provide us details screen shots with steps from scratch?

Regards


Not able to retrieve data from a JavaScript Rest Service after the update

Posted: Thu Sep 25, 2014 6:09 am
by Asif

Hi Yurii,
1.This is the first page of my app (Login Page)
Give "pos001" as login id

Image

2.This is the second page, in which you have to give a secret code. Give "123456"

Image

3.Once you click on Register you will get this popup

Image

  1. Then open the panel and click on Sync Tibbs Menu list item(It will get the menu from cloud db to local db)

    Image

  2. Now you will see Three buttons on "posDashBoard" page. Click on Veg button.
    On this button click event i have called the Rest Service which will retrieve data from menu table in the local db and show it on the page.(I am able to fetch the data from local db, but data is not getting displayed on the page).

    Image


Not able to retrieve data from a JavaScript Rest Service after the update

Posted: Fri Sep 26, 2014 1:53 am
by Yurii Orishchuk

Hi Asif,

You pass to "succees" event string, but object should be.

See details: http://prntscr.com/4qd1h0/direct

Here is correct code:

pre

var db = window.openDatabase("TIBBSPOSDB", "", "TIBBSPOSDB", 1024 * 1000);

Appery.getVegMenuJS = Appery.createClass(null, {

Code: Select all

 init : function(requestOptions) { 
     this.__requestOptions = $.extend({}, requestOptions); 
 }, 

 process : function(settings) { 
     settings.beforeSend(settings); 
     if (this.__requestOptions.echo) { 
         settings.success(this.__requestOptions.echo); 
     } else { 
        // console.log('Default implementation is used. Please define your own.'); 

         var ourFinalArray = []; 
         var productCategory='v'; 
         db.transaction(function(tx) { 
             tx.executeSql('SELECT * FROM "menu" WHERE productCategory = ? ', [productCategory], function(tx, results) { 

                  console.log("getMenu call made"); 
                 var len = results.rows.length, 
                     i; 

                 Apperyio.storage.vegLength.set(len); 
                 if (len === 0) { 

                     console.log('inside if'); 
                 } else { 
                     for (i = 0; i < len; i++) { &#47;&#47; for each row 
                         ourFinalArray&#46;push(results&#46;rows&#46;item(i)); &#47;&#47; pushing row object to an array                 

                     } 
                      console&#46;log("Menu: " + JSON&#46;stringify(ourFinalArray)); 
                     &#47;&#47;settings&#46;success(JSON&#46;stringify(ourFinalArray)); 
                     settings&#46;success(ourFinalArray); 

                 } 
                 settings&#46;complete('success'); 
             }); 
         }); 
     } 
 } 

});

/pre

Regards.


Not able to retrieve data from a JavaScript Rest Service after the update

Posted: Fri Sep 26, 2014 9:57 am
by Asif

Hi Yurii,
After making this change, it is working fine but in the Appery Tutorial it is this
settings.success(JSON.stringify(ourFinalArray));
see the screen shot Image


Not able to retrieve data from a JavaScript Rest Service after the update

Posted: Sun Sep 28, 2014 9:57 pm
by Yurii Orishchuk

Hi Asif,

It's very depends on what you should do with this service.

Actually you can return string as response, but in this case you should work with this response as string. Appery.io mapping require pure object in response to be used in mapping feature.

Anyway, we glad you got working it.

Regards.


Not able to retrieve data from a JavaScript Rest Service after the update

Posted: Tue Sep 30, 2014 7:21 am
by Asif

Hi Yurii,
Now there is one more service in my app in which i m retrieving data from local db and displaying it on the screen. Here i m mapping object instead of the string but still not getting the response displayed on the screen.

Steps to replicate this issue

Follow the steps mentioned above and when you click on Veg Button you will get list of all the products.
Then click on plus button. On the click of this button i have written a JS in which i m calling "getCartItems" service and its mapping is present on "ipadscreen1" page.


Not able to retrieve data from a JavaScript Rest Service after the update

Posted: Tue Sep 30, 2014 11:16 pm
by Yurii Orishchuk

Hi Asif,

May be problem in error message?

See details: http://prntscr.com/4rwzkr/direct

Regards.