Here: https://github.com/fac-u/autocompleter/blob/master/src/autocomplete.js#L7
Synchronous reads are blocking and will stop your server from responding to subsequent requests while it completes. Not a big deal here, but in a real project it can be a problem. It's best to avoid synchronous operations if possible.
You are also reading the orderedDict.json every time you call the autocomplete function. This is quite inefficient.
A better solution which would avoid having to change the API of your autocomplete function to be asynchronous would be to read the orderedDict.json into memory when the server starts. Then your function would simply reference an in-memory object (relatively fast) instead of reading a file (relatively slow).
Here: https://github.com/fac-u/autocompleter/blob/master/src/autocomplete.js#L7
Synchronous reads are blocking and will stop your server from responding to subsequent requests while it completes. Not a big deal here, but in a real project it can be a problem. It's best to avoid synchronous operations if possible.
You are also reading the
orderedDict.jsonevery time you call theautocompletefunction. This is quite inefficient.A better solution which would avoid having to change the API of your
autocompletefunction to be asynchronous would be to read theorderedDict.jsoninto memory when the server starts. Then your function would simply reference an in-memory object (relatively fast) instead of reading a file (relatively slow).