Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use Array.push inside once() #1332

Open
nexhero opened this issue Jun 9, 2023 · 1 comment
Open

Unable to use Array.push inside once() #1332

nexhero opened this issue Jun 9, 2023 · 1 comment

Comments

@nexhero
Copy link

nexhero commented Jun 9, 2023

If I do a hard refresh I got this error,
but If I came from my menu page, it's loads with no errors

Uncaught TypeError: Cannot add property 1, object is not extensible
at Array.push ()
at Gun. (product.js:37:1)
at once (gun.js:1250:1)

My method functions

export function fetchUserProducts(pub) { return new Promise((resolve, reject) => { g.user(pub).get(PRODUCT_PATH, async function(ack) { if (ack.err) { reject(ack.err); } else if (!ack.put) { reject('Unable to load products'); } else { const list = []; g.user() .get(PRODUCT_PATH) .map() .once(function(product, id) { const p = { id: id, name: product.name, }; list.push(p); }) .once(async function() { resolve(list); }); } }); }); }

pd: sorry for my format code :(

@nexhero
Copy link
Author

nexhero commented Jun 10, 2023

This kinda solve the issue, sometimes still got the error
var list = [] return new Promise((resolve, reject) => { gun.user(pub).get(PRODUCT_PATH).map().once((product, id) => { const p = { id: id, name: product.name, }; list.push(p); }).then(() => { resolve(list); }).catch((err) => { reject(err); }); });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant