Returning results from server requests - REST

Hello,

I’m currently using this REST CLIENT Rest Client for Unity | Network | Unity Asset Store to make calls to a server, data is returned as JSON.

Is it possible to return the data to a calling method from another class?

e.g.
Class A has a method that calls Class B, Class B calls server, then returns data to class A.

Example code to Post data to server, I want response to be sent back to calling method, is this possible?

 RestClient.Post(URL.player, JsonUtility.ToJson(sessionData)).Then(data => {

            JSON.Session.Return JSONReturn = JsonUtility.FromJson<JSON.Session.Return>(data.Text);

            Debug.Log(data.Text); 
}).Catch(err => {
      Debug.Log(err.Message);
});

Any help would be much appreciated. Thank you.

No, not to a “normal” method since web requests are asynchronous. So waiting for the response would completely freeze the main thread and application. It’s possible with a coroutine of async methods, but this in some sense is the same as having a callback, just different syntax. You haven’t provided an actual usecase. You just showed your Post call. What does the calling method look like?