RestClient for Unity
PROJECT
Part of: Proyecto 26
Fiscal Host: Open Source Collective
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
Juan David Ni...
Admin
Contribute
Become a financial contributor.