Skip to content

Commit

Permalink
[Fix] GO-SOPT-iOS-Part#12 - 서버통신 함수 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
kj9470 committed Jul 2, 2023
1 parent 00d5546 commit 3770c80
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ extension ContentService: TargetType {
var path: String {
switch self {
case .fetchContent:
return "/3/movie/popular"
return URLConst.contentURL
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@ public enum URLConst {

// MARK: - URL Path

public static let contentURL = "/3/movie/popular?api_key=5ef8d1b433c1a9970f7ade5c76cc090d&language=ko-KR"

public static let contentURL = "/3/movie/popular"
}
Original file line number Diff line number Diff line change
Expand Up @@ -300,18 +300,15 @@ extension HomeViewController {
contentProvider.request(.fetchContent) { response in
switch response {
case .success(let result):
let status = result.statusCode
if status >= 200 && status < 300 {
do {
do {
let status = result.statusCode
if status >= 200 && status < 300 {
guard let data = try? JSONDecoder().decode(ContentResponse.self, from: result.data) else { return }
self.contentModel = data.convertToContent()
self.homeCollectionView.reloadData()
} catch (let error) {
print(error.localizedDescription)
}
}
else if status >= 400 {
print("400 error")
} catch (let error) {
print(error.localizedDescription)
}
case .failure(let error):
print(error.localizedDescription)
Expand Down

0 comments on commit 3770c80

Please sign in to comment.