Anuj Puri
Posts: 0
Joined: Wed Dec 31, 2014 4:24 pm

If local storage null not working

So, I just tried what you've suggested: I created another local storage variable (outpan_success_count). So, for the rest service that sends the barcode to outpan and then retrieves the item name, here's what I did:

For Before Send, I set the storage variable outpan_success_count to 0. Then, after the success event, I set the variable to 1. After a fail event, I sent it to 2. Then, after the complete event, I run javascript, and all it does is alert the value of the outpan_success_count variable: alert(localStorage.getItem('outpan_success_count'));

So, when running this, if i use a barcode that outpan finds, it alerts me with a 1
However, if I scan a barcode that outpan does NOT find, nothing happens. There's absolutely no alert.

But, here's the thing, if I place that javascript code to alert the outpan_success_count in the success event BEFORE the mapping, it works and outputs a 1 for a barcode that outpan does not find. But if I move the javascript to AFTER the mapping, it does not work. So, apparently the api call is succeeding, however mapping a blank name onto the local variable is breaking any further coding. Does this make sense?

M&M
Posts: 0
Joined: Tue Nov 11, 2014 6:59 am

If local storage null not working

There are 2 things that are at work here

  1. Reading the bardcode (With a Success / Failure). Handle the first Failure here

  2. If it is successful, then do a lookup (against your database?). Again this part will have a success / failure. If it has failed here, handle this "second" failure

    Hope that's clear

Anuj Puri
Posts: 0
Joined: Wed Dec 31, 2014 4:24 pm

If local storage null not working

That's what I've been doing. The barcode scan (reading the barcode) has always been a success so far. It's the next part (the lookup, which is not against my database but a restful api call to outpan.com). This api then returns the name of the barcode. If the name is returned, everything works fine, but if "name": null; is returned, it doesn't work, including that counter you suggested i try, so not sure what's going on.

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

If local storage null not working

Hello Anuj,

Sorry for delay. Could you please clarify a few things:
1) have you added any console logs or alerts on error event?
2) please clear your LSV on before send event.

Anuj Puri
Posts: 0
Joined: Wed Dec 31, 2014 4:24 pm

If local storage null not working

I've done both. The log shows the variable empty after the barcode is searched. and I set the LSV to empty before I run the barcode scanner.

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

If local storage null not working

Anuj,

Please share your app with a href="mailto:support@appery.io" rel="nofollow"support@appery.io/a and provide us with the following information:

1) App name
2) Test credentials if login functionality is implemented in your app
3) Detailed steps to reproduce the issue

http://devcenter.appery.io/documentat...

M&M
Posts: 0
Joined: Tue Nov 11, 2014 6:59 am

If local storage null not working

[quote:]
(the lookup, which is not against my database but a restful api call to outpan.com). This api then returns the name of the barcode. If the name is returned, everything works fine, but if "name": null; is returned, it doesn't work
[/quote]

Anuj just check the length of the variable that holds the name, after your rest call to outpan. If it's zero then it has failed to find the item. That way you can decide on the success or failure

Anuj Puri
Posts: 0
Joined: Wed Dec 31, 2014 4:24 pm

If local storage null not working

M&M... I've tried that already as well. Right from the start, my first post, I tried: outpanname.length < 1, which still didn't work.

M&M
Posts: 0
Joined: Tue Nov 11, 2014 6:59 am

If local storage null not working

Tried trimming the variable or output for spaces? Could there have been space(s)?
And i guess you reset/clear variables before every call to the API. I don't see another reason why your LSV still.holds/gets populated with something. Have you tried writing the var length to the console to have some idea if its holding anything at all

Anuj Puri
Posts: 0
Joined: Wed Dec 31, 2014 4:24 pm

If local storage null not working

I looked and couldn't detect any spaces. Nor is outpanname == null after the search, even though the api call returns "name": null;

the null is in a blue color when i run a test of the api within appery. does it being blue make any difference or mean anything?

Return to “Issues”