We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
이번에 4차과제를 하면서 반복되는 judgeStatus 메서드를 하나로 통일할 수 있도록 아래와 같이 만들어봤는데 어떻게 생각하시나용? @hyun99999 @yangsubinn
func myRoomCertiChangeFetch(roomID: Int, lastID: Int, size: Int, completion: @escaping (NetworkResult<Any>) -> Void) { userProvider.request(.myRoomCertiChangeFetch(roomID: roomID, lastID: lastID, size: size)) { (result) in switch result { case .success(let response): let statusCode = response.statusCode let data = response.data let networkResult = self.judeStatus(by: statusCode, data, type: MyRoomCertification.self) completion(networkResult) case .failure(let err): print(err) } } } private func judgeStatus<T: Codable>(by statusCode: Int, _ data: Data, type: T.Type) -> NetworkResult<Any> { let decoder = JSONDecoder() guard let decodedData = try? decoder.decode(GenericResponse<T>.self, from: data) else { return .pathErr } switch statusCode { case 200: return .success(decodedData.data ?? "None-Data") case 400..<500: return .requestErr(decodedData.message) case 500: return .serverErr default: return .networkFail } }
The text was updated successfully, but these errors were encountered:
너무 좋네요! 확실한 리펙입니당 지금 200 혹은 201 일때 성공하는 경우가 있을 수도 있고 400 이랑 500 사이에 분기처리가 있는 경우도 있어요! 유의해서 진행하면 좋을거 같네용 준호 멋집니당🙈
Sorry, something went wrong.
좋슴니다 ! 훨씬 더 효율적일 것 같아요 🤓
L-j-h-c
No branches or pull requests
🛠 Issue
이번에 4차과제를 하면서 반복되는 judgeStatus 메서드를 하나로 통일할 수 있도록 아래와 같이 만들어봤는데 어떻게 생각하시나용?
@hyun99999 @yangsubinn
📝 To-do
The text was updated successfully, but these errors were encountered: