Harybo Posted October 23, 2019 Posted October 23, 2019 hello, i need some help for my function, i make it returned a value under JSON.stringify but since it's an asynchronous function, it sends it to me with promise {result} so I can not use JSON.parse after. If you have a solution to my problem, I do not mind async getItemForPlayerMenu(id) { const playerItem = []; const data = await misc.query(`SELECT u.*, i.itemName, i.usable, i.itemcount FROM user_items u LEFT JOIN items i ON i.id = u.itemId WHERE u.charId = "${id}"`); for (const item of data) { if (item.charId !== id) continue; const v = { id: item.id, owner: item.charId, itemId: item.itemId, amount: item.amount, title: item.itemName, usable: item.usable, poids: item.itemcount } playerItem.push(v); } return JSON.stringify(playerItem); } Promise { '[{"id":1,"owner":6,"itemId":1,"amount":10,"title":"Eau","usable":"Y","poids":1},{"id":2,"owner":6,"itemId":2,"amount":10,"title":"Sandwich","usable":"Y","poids":1}]' }
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now