RestClient
RestClient copied to clipboard
Stupid question, but what is the recommended way to return a value from a method?
All the code examples have void as the return type.
But I would like to create some of my methods that make a REST API call return a value. What is the recommended method to do this with this Promise based library considering it doesn't support async/await?
I'm thinking of just having one of my method params being an Action
i.e
public void Post(string param1, Action<bool, string> callback)
{
RestClient.Post<Post>(currentRequest)
.Then(result =>
{
callback(true, JsonUtility.ToJson(result, true));
})
.Catch(err => callback(false, err.Message));
}