Coder Social home page Coder Social logo

Comments (8)

skydoves avatar skydoves commented on May 20, 2024

Hey @ldileh, what is the return type of the otpVerification method? You should return a non-nullable type for using it.

from sandwich.

ldileh avatar ldileh commented on May 20, 2024

otpVerification return ApiResponse<BaseResponse<TokenResponseModel>>.

inside the class BaseResponse is :
@Keep @Serializable data class BaseResponse<T>( @SerializedName("error") val error: ErrorModel? = null, @SerializedName("success") val success: Boolean?, @SerializedName("data") val data: T? = null )

and for class TokenResponseModel is :
@Keep data class TokenResponseModel( @SerializedName("accessToken") val accessToken: String?, @SerializedName("refreshToken") val refreshToken: String? )

from sandwich.

skydoves avatar skydoves commented on May 20, 2024

@ldileh What happens if you add !! at the end of the otpVerification method?

from sandwich.

skydoves avatar skydoves commented on May 20, 2024

I just tested with the demo project and it looks work for me.

interface DisneyService {
  
  @GET("")
  suspend fun fetchItems(): ApiResponse<BaseResponse<List<Poster>>>
}

    val retryPolicy = object : RetryPolicy {
      override fun shouldRetry(attempt: Int, message: String?): Boolean = false

      override fun retryTimeout(attempt: Int, message: String?): Int  = 3
    }

    runAndRetry(retryPolicy) { _, _ ->
      disneyService.fetchItems()
    }

from sandwich.

ldileh avatar ldileh commented on May 20, 2024

oh great it's work! what happens in that part?

from sandwich.

skydoves avatar skydoves commented on May 20, 2024

I don't know the details of the otpVerification method, but it returns a nullable type for some reason.

from sandwich.

ldileh avatar ldileh commented on May 20, 2024

then what if the body response had case null? how can I handle that part?

let's say, the problem is in the endpoint :
case 1: success it returns json body
case 2 : It return success HTTP code, but for some reason, the body is null because the endpoint had a problem.

how can I handle case 2? it will turn to method onError or onException automatically?

usually I handle this case with nullable symbols. That way, usually the application won't crash and we just have to handle the null response

from sandwich.

ldileh avatar ldileh commented on May 20, 2024

ah sorry @skydoves, I just read the documentation again. apparently I can use getOrNull(). stupid of me lol
thanks btw bro @skydoves for your support

from sandwich.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.