Skip to content

Request Post

D edited this page Dec 18, 2018 · 2 revisions
        Params params = new Params("https://api.douban.com/v2/movie/top250");
        params.addParam("start", "1");
        params.addParam("count", "10");
        Aster.post("top250", params)
                .baseUrl("https://api.douban.com/v2/movie/")
                .connectTimeout(5 * 1000)
                .readTimeout(5 * 1000)
                .writeTimeout(5 * 1000)
                .request(new AsyncCallback<MovieInfo, String>() {
                    @Override
                    public String apply(@NonNull MovieInfo info) throws Exception {
                        ...do something in asynchronous thread, such as time-consuming, map conversion, etc.
                        return "";
                    }

                    @Override
                    public void onSuccess(String response) {
                        ...do something in main thread
                    }

                    @Override
                    public void onError(Throwable e) {
                        ...do something in main thread
                    }
                });
Clone this wiki locally