相关疑难解决方法(0)

改造正在返回缓存的响应

我在 Android 应用程序中使用 Retrofit。当我使用令牌访问 API 以获取用户信息时,它会提供缓存的(先前的)响应。每当我注销并再次登录时,API 都会提供以前的用户详细信息,我在 Postman 中测试了 API,它在那里工作正常。

我尝试了一些我搜索过的解决方案,但没有任何效果。

我得到的响应头是

传输编码:分块内容类型:应用程序/json;charset=utf-8 服务器:Kestrel 日期:2018 年 1 月 8 日星期一 09:35:26 GMT

下面是ApiClient

public class ApiClient {

public static final String BASE_URL = "http://XX.XXX.XXX.XX/api/";
private static Retrofit authRetrofit = null;
private static Retrofit retrofit = null;

public static Retrofit getClient() {

    if (retrofit == null) {
        retrofit = new Retrofit.Builder()
                .baseUrl(BASE_URL)
                .addConverterFactory(ScalarsConverterFactory.create())
                .build();
    }
    return retrofit;
}

 public static Retrofit getAuthorizeClient(final String token) {

    OkHttpClient.Builder httpClient = new …
Run Code Online (Sandbox Code Playgroud)

android retrofit2

2
推荐指数
1
解决办法
2251
查看次数

标签 统计

android ×1

retrofit2 ×1