Open nexhero opened 1 year ago
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); }); });
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 :(