Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
What are my options here? Do I need to switch the module I'm using to access the db? Do I need to write C code? Or is there a really clever technique to directly solve this problem, using only nod...
Answer
#1: Initial revision
> What are my options here? Do I need to switch the module I'm using to access the db? Do I need to write C code? Or is there a really clever technique to directly solve this problem, using only nodejs? Generally, you shouldn't be turning asynchronous functions into synchronous ones. I would suggest to first look at your code and ask yourself, do you *need* `readFileSync`? Node.js practically revolves around callbacks and asynchronous programming, so such a use case should be extremely rare. If you actually do need it, then I would then suggest just switching modules to one which has synchronous functions, since you will likely be needing to write other synchronous functions as well and it's better just to get a module with support for that. --- **Last resort** If all else fails... there do exist modules, such as [deasync](https://github.com/abbr/deasync), which convert asynchronous functions into synchronous ones.