title: How to resolve an Either[Error, User] in Complete- Akka HTTP
body: <p>I am new in Akka HTTP and I am trying to define the endpoint below. </p>
  
  <p>In routes level I have this endpoint:</p>
  
  <pre><code>def login: Route = {
    post(
      entity(as[UserLogin]) { userLogin =&gt;
        complete(
          authService.loginUser(userLogin)
        )
      }
    )
  }
  </code></pre>
  
  <p>the signature of <code>authService.loginUser</code> is</p>
  
  <pre><code>def loginUser(userLogin: UserLogin): Either[Error, UserDto]
  </code></pre>
  
  <p>The question is how can I resolve the <code>Either[Error, UserDto]</code> in routes coz now I got this error</p>
  
  <pre><code>Type mismatch, expected: ToResponseMarshallable, actual: Either[Error, UserDto]
  </code></pre>
  
  <p>UserDto case class</p>
  
  <pre><code>case class UserDto(id: Int,
                 username: String,
                 email: String,
                 firstName: String,
                 lastName: String,
                 balance: BigDecimal) {
  implicit def UserDtoCodecJson: CodecJson[UserDto] =
  casecodec6(UserDto.apply, UserDto.unapply)(
    "id", "username", "email",
    "firstName", "lastName", "balance"
  )
  }
  </code></pre>
  
  <p>Many thanks in advance. </p>