Open Collective
Open Collective
Loading

RestClient for Unity

PROJECT
Part of: Proyecto 26

Simple HTTP and REST client for Unity based on Promises, also supports Callbacks! ๐ŸŽฎ

About


RestClient for Unity ๐Ÿค˜

This HTTP/REST Client is based on Promises to avoid the Callback Hell โ˜ ๏ธ and the Pyramid of doom ๐Ÿ’ฉ working with Coroutines in Unity ๐ŸŽฎ, example:

var api = "https://jsonplaceholder.typicode.com";
RestClient.GetArray<Post>(api + "/posts", (err, res) => {
  RestClient.GetArray<Todo>(api + "/todos", (errTodos, resTodos) => {
    RestClient.GetArray<User>(api + "/users", (errUsers, resUsers) => {
      //Missing validations to catch errors!
    });
  });
});
But working with Promises we can improve our code, yay! ๐Ÿ‘

RestClient.GetArray<Post>(api + "/posts").Then(response => {
  EditorUtility.DisplayDialog ("Success", JsonHelper.ArrayToJson<Post>(response, true), "Ok");
  return RestClient.GetArray<Todo>(api + "/todos");
}).Then(response => {
  EditorUtility.DisplayDialog ("Success", JsonHelper.ArrayToJson<Todo>(response, true), "Ok");
  return RestClient.GetArray<User>(api + "/users");
}).Then(response => {
  EditorUtility.DisplayDialog ("Success", JsonHelper.ArrayToJson<User>(response, true), "Ok");
}).Catch(err => EditorUtility.DisplayDialog ("Error", err.Message, "Ok"));

Our team

Contribute


Become a financial contributor.

Financial Contributions

Custom contribution
Donation
Make a custom one-time or recurring contribution.