Relative Content

Tag Archive for node.jswebsocketasync-awaitnode-mysql2

How to access mysql2 SELECT results outside of async/wait to send over websocket

I currently use PHP and AJAX to select the passwords I have saved in my database and them send them back. Depending on the search terms, or if the passwords are being re-encrypted, the request can take a while with no feedback, besides using a spinner. I use a node websocket server on other pages and thought I could migrate it from AJAX/fetch to use websockets so I could send the page a realtime progress report. I have used promise/then but figured I would learn to use async/wait functions on the parts that were dependent on the long queries and re-encryption. I am using mysql2/promise module and can get the data out of the DB and print it to the console but am unable to do anything with it outside of an async function (which kind of makes sense to me, wont the rest be ticking away doing its own thing while the await is awaiting?) What I have tried to do is pass the websocket callback paramter (is this the correct term) into the function but it just silently does nothing.