-
Notifications
You must be signed in to change notification settings - Fork 5
Description
Hello Fluffy9,
I looked at your changes!
The line:
if (!data['data']['!']) {cb(null, JSON.stringify(data['data']) || undefined)} else { cb(null, undefined)} })
you just have to change it like this:
cb(null, JSON.parse(data['data']) || undefined) })
The line in "store.put" is much more important for you
client.db.setJSON(privateKey, key, data).then(() => {cb(null,1)}).catch(err => {
in new:
client.db.setJSON(privateKey, key, JSON.parse(data)).then(() => {cb(null,1)}).catch(err => {
Now it should be right!!!!!
To test if it works!!!! :
Important for TEST! Please set a new secret!!
- just run gun.get('hello').put({ name: "SuperWorld" }); but please before comment out this line:
gun.get('hello').on(data => { hello_world = data['name']; alert("hello: " + hello_world)
Please don't bother if the new SECRET shows a few errors in the browser console! Two passes no longer show errors!
#######
- So that it outputs a clean log in the browser console, please repeat the procedure as in number 1!
Now the new value "SuperWorld" is under the key "hello"! all ok
Next, we'll pick up the "hello" key again! see number 3!
#######
- only execute gun.get('hello').on(data => { hello_world = data['name']; alert("hello: " + hello_world), but PLEASE first comment out this line gun.get('hello ').put({ name: "SuperWorld" });
Very important for test nr 3! comment out gun.get('hello').put({ name: "SuperWorld" });
Now with Gun Options (localStorage: false, and radisk: false,) the result "hello: SuperWorld" should be displayed in the browser console!
For gun options, you should use
file: "skydb1",
radisk: false,
Very important! The first option file: "skydb1", is only so that the test does not use the old db from the browser, but creates a new empty one, so that there are no incorrect results!
The second option is also important radisk: false, this tells Gun that should save und get no data in/from the new browser db "skydb1", but with every query that retrieves new data from SKYNET!
So they always have the latest data!
-
It could be if a friend of yours with the same SECRET in another browser or another location issued the command:
gun.get('hello').put({ name: "SuperWorld222" });
To run! -
Now if you do nr 3 again!
The newest result should now show "hello: SuperWorld22" in the browser console!!
If you didn't have gun options "radisk: false," gun would fetch data from browser db first and then later from skynet and it would be different results!
Have fun testing
Can tell me about the bugs and success