public HttpPromise <Post, string> GetPost(long id) { return(HttpPromise <Post, string> .Get( this.baseUrl + "posts/" + id, (request, promise) => { if (request.isNetworkError || request.isHttpError) { promise.Error = request.error; } else { promise.Result = JsonUtility.FromJson <Post>(request.downloadHandler.text); } })); }
public HttpPromise <List <Post>, string> GetPosts() { return(HttpPromise <List <Post>, string> .Get( this.baseUrl + "posts", (request, promise) => { if (request.isNetworkError || request.isHttpError) { promise.Error = request.error; } else { var josn = "{\"list\":" + request.downloadHandler.text + "}"; promise.Result = JsonUtility.FromJson <PostList>(josn).list; } })); }