Any help appreciated - I’m having trouble getting to grips with why the code below fails. I have a rules engine in which the steps must be executed in sequence because each rule may assess the results of previous rules, so these have to be available.
Thanks so much for your reply. I think I didn’t explain my situation properly though.
I understand that I can call an async version of mycaller() and how this works. My issue is that my mycaller() function in this stripped-down example represents thousands of lines of synchronous code in my “real” application, so what I’m trying to do is add one asynchronous call to chatGPT to these.
To explain a little further, I have a rules engine where each rule may require values that result from earlier rule evaluations. The logical way to code this is to evaluate them in sequence, synchronously. Theoretically it would be possible to code asynchronously with each callback re-building the tree of values but this would be really weird and a nightmare to debug.
I am not sure if I totally I understand. Based on your example I see a simple mistake. Your getMiddle function does not have a return statement. You are combining await with .then. I would use one OR the other. For example I would change getMiddle to: