neoGetItem resulted in "Invalid character" error message - Forum

Forum Navigation
You need to log in to create posts and topics.

neoGetItem resulted in "Invalid character" error message

Hi @luishp, I was trying out the neoLocalStorage plugin, and replacing the getItem/SetItem with the neoGetItem and neoSetItem.

After creating a new db with neoSetItem, subsequent attempt to retrieve the db using neoGetItem resulted in the 'invalid character" error.  Note sure why I've done wrong as the assumption is simply to replace GetItem with neoGetItem, and SetItem with neoSetItem

Attached is a modified sample using neoLocalStorage...

Uploaded files:
  • You need to login to have access to uploads.

Hi @ronnie, please note neoSetItem and neoGetItem are asynchronous. So to be sure the data has been loaded you must process it into a subroutine (third parameter) or use a Wait command to be sure the data is available when the next command is executed.
I think @noyzen probably faced the same problem.

Regards.

Hi @luishp, I'm aware of the asynchronous part. Thanks.. will need to review...

Hi @luishp, I noticed each time I created the db, it's shown in IndexDB section. However, when I rerun the project again, it couldn't find the earlier DB and created a new DB. Is this only a 'session-like' db where when the program exited, the db is cleared?

Is this only a 'session-like' db where when the program exited, the db is cleared?

@ronnie not it isn't. Unless your web browser is configured to delete the cookies once you close the window. If you press F5 to reload the application you should be able to load the saved data. Anyway try testing using an "http://" protocol (with neoPhp Server or any other web server) instead of the default "file://" as this one has more security restrictions.

Hi @luishp. Yeah, it's probably due to my side.

The funny thing is when I changed back all reference to neoSetItem to SetItem, and neoGetItem to GetItem, whatever I added to the user record , saved it, I noticed the file was updated in LocalStorage file. However, when I replace the GetItem/SetItem with neoGetItem/SetItem, I noticed only the initial created records are saved. Subsequent adding of records, while shown correctly on the neoTable, was not updated to the IndexDB file. I even tried pressing F5 to refresh...

It's puzzling as what you've suggested - simply replace GetItem/SetItem with neoGetItem/neoSetItem and the  project should run...  LocalStorage works fine... but not neoLocalStorage. 8((

@ronnie as you know neoLocalStorage is a LocalForage library wraper. I have not extensively tested it but the few tests I did were ok. Will try to do a closer look as soon as I can.

Thank you!

Hi @luishp, thanks. Hopefully we can identify the root cause...

@ronnie note that using neoSetItem and neoGetItem you can save and load JSON data directly. No need to stringify the JSON to save it nor parse the JSON to use the data again. That process is done automatically. I think the problem could be there.
Regards.