Passing a string back through IPC callback?

I have an IPC app where I want to callback after I’ve read a line from a text file and the callback works fine but how can I pass the string back?

Is there a way to do this?
At the moment I’m thinking I just store the variable globally and call back and then have the call back function call another api function that is synchronous and returns the string.
Is there a better way or is this appropriate? thanks

Client-----------------------Server-----------------server----------------------client -----------------------server
Calls fileReader ------> reads file ----------> calls call back--------->calls getString----------->returns string

Is there examples of how to do this anywhere?

I did this and it worked so eh good enough