Page 1 of 1

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

Posted: Tue Oct 15, 2013 9:31 pm
by Gregory Vaughan

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)


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

Posted: Tue Oct 15, 2013 9:42 pm
by Gregory Vaughan

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.


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

Posted: Tue Oct 15, 2013 10:45 pm
by Illya Stepanov

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


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

Posted: Tue Oct 15, 2013 10:53 pm
by Gregory Vaughan

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


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

Posted: Tue Oct 15, 2013 11:13 pm
by Illya Stepanov

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


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

Posted: Wed Oct 16, 2013 2:37 pm
by Gregory Vaughan

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


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

Posted: Wed Oct 16, 2013 3:47 pm
by Oleg Danchenkov

Hi Gregory.
Please check this post https://getsatisfaction.com/apperyio/...