Gregory Vaughan
Posts: 0
Joined: Thu Sep 19, 2013 8:49 pm

How to display a message when rest service returns no rows (... or one row)

This is probably very basic but I'm not seeing it anywhere. I have tried a couple things, for example, mapping a field which will always be present on every record to a local storage variable, and running this javascript on complete:

if (!localStorage.getItem('RecordID'))
{
Appery('error').text('No records meeting criteria found.');
}

No worky. (Actually I think I saw it work once but never again which is even stranger).

Then my next, related question will be, how can I do something conditionally if only one row is returned (for example, I won't have to prompt user to select from a list of options I can skip ahead to next screen)

Gregory Vaughan
Posts: 0
Joined: Thu Sep 19, 2013 8:49 pm

How to display a message when rest service returns no rows (... or one row)

I found my problem trying to do this with a local storage variable. Need to clear the variable out before invoking the service. :)

Any suggestions on how to do this better, or for when one row is returned, would be appreciated.

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

How to display a message when rest service returns no rows (... or one row)

Hi Gregory -- you can use
pre
localStorage.removeItem('foo');
/pre

  • to remove previously defined 'foo' element in localStorage;

    or you can clear completely all elements in localStorage, before defining a new one:
    pre
    localStorage.clear();
    /pre

Gregory Vaughan
Posts: 0
Joined: Thu Sep 19, 2013 8:49 pm

How to display a message when rest service returns no rows (... or one row)

Can you tell me how I might go about displaying a message or doing something when a rest service returns only one row?

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

How to display a message when rest service returns no rows (... or one row)

You are using DataBase with data or what exactly is 'a row' which is returning?

Gregory Vaughan
Posts: 0
Joined: Thu Sep 19, 2013 8:49 pm

How to display a message when rest service returns no rows (... or one row)

It's a php file that makes a json from a mysql query.

Return to “Issues”